Skip to content
Advertisement

Alternative to cron that retains environment variables

I have been trying to set up a cron job to run a bash script every 30 minutes on a Linux-based compute cluster. The problem is that some functions normally available in my shell are not available to the cron job, causing it to crash. I import all my environment variables (including the ~/.bashrc) but no luck, so I am clearly still missing something but have been unsuccessful in identifying what that may be.

As a result, I am trying to find an alternative to cron that mimics the normal login environment to avoid this issue altogether. Does anyone have any suggestions?

Advertisement

Answer

Set path at the beginning of your script:

# for example:
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement