0

I have a script job.sh in /home/user/scripts, which is then symlinked to /home/user/bin/job. The custom binaries path has been included in .bashrc, so whenever I issue the command job param1 etc from the cli everything works as expected.

When said command has to be run through a cronjob, it doesn't. On the other hand, if the cronjob refers to the full path (/home/user/bin/job instead of simply job) everything runs fine.

Any pointer on how to tackle this issue?

1

cron intentionally runs with a limited environment (including a restricted path, it does not have the same path as your standard shell).

You either need to run a script (including the full path to the script) which then sets a path variable internally, or you need to set the path in the crontab line itself.

One example of that is,

12 0 * * * (export PATH=$PATH:/somedirectory; job)

Really though, it's safer to just include the full path to whatever you're running in the crontab, and set the path correctly in your scripts that cron executes.

  • got it, thanks for the clear explaination! – nxet Apr 26 '16 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.