0
votes

Im trying to run a simple script with crontab and it does not run, I tried to write the output to log but it doesn't write anything, here is what i did:

crontab -e

then I have added my shell script (Which it running perfect if I run it manually):

*/1 * * * * /script/check.sh > /script/output.log

(yes, I need to run this script every minute), its simple script that check if another script is running.

any idea why its not running from the crontab but indeed running well from console?

BTW: I have direct admin, and if Im running it from there it running well, But I need root permissions, thats why Im using the crontab.

Thanks in advance!

Eran.

1
Does the script depend on environment variables, such as $PATH, that are set in .profile? No shell startup scripts are run when a program is run from cron. - Barmar
If you just put echo running in the script, does it work? - Barmar
it using grep only, I have added this anyway: SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin, its not help.. - Eran Levi
Are you sure you have the path to the script correct? Are there any messages in the system log? - Barmar
actually no, I can't see nothing it output.log - Eran Levi

1 Answers

0
votes

Ok, found it, Im not sure why, but I had to add "sh" before my script to make it work, anyway its working fine now, thanks!:

*/1 * * * * sh /script/check.sh > /script/output.log