4
As root I added used crontab -e
to add my script. However the script uses a binary in /usr/sbin/
and I get an error about it not existing when the script runs from cron. How do I fix this?
4
As root I added used crontab -e
to add my script. However the script uses a binary in /usr/sbin/
and I get an error about it not existing when the script runs from cron. How do I fix this?
7
You should just use the full path for the binary.
So let’s say you wanted to use ipconfig
in a cron job. Instead of your crontab having a command like this:
ipconfig
You would change that to be:
/usr/sbin/ipconfig
Remember: Shell paths just tell the system where to look for binaries/executables when you call them from the command line to make your life typing commands easier. Providing the full path for binaries/executables works 100% the same for script use.
3
Probably not the cleanest approach, but
You can set PATH variable in crontab, put this as the first line of your crontab
# start of crontab file
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# your cron entries below