Saturday, April 27, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 74440  / 3 Years ago, sat, october 23, 2021, 7:40:26

I have a setup as below but its never getting executed.



$ chmod +x /var/tmp/myscript.sh
$ vim /var/tmp/crontab.sh;
* * * * * sleep(10); /var/tmp/myscript.sh
$ crontab /var/tmp/crontab.sh


Now just, noticed its not working. What am i doing wrong?



$ grep CRON /var/log/syslog
Nov 28 15:20:01 sun CRON[1768]: (sun) CMD (sleep(10);/var/tmp/myscript.sh)
Nov 28 15:20:01 sun CRON[1766]: (CRON) error (grandchild #1768 failed with exit status 2)
Nov 28 15:20:01 sun CRON[1766]: (CRON) info (No MTA installed, discarding output)


Follow up:



$ vim /var/tmp/crontab.sh
* * * * * sleep 10; /var/tmp/myscript.sh>/dev/null 2>&1
$ tail -f /var/log/syslog | grep CRON
Nov 28 15:50:02 sun CRON[2301]: (sun) CMD (sleep 10; /var/tmp/myscript.sh>/dev/null 2>&1)
Nov 28 15:51:01 sun CRON[2312]: (sun) CMD (sleep 10; /var/tmp/myscript.sh>/dev/null 2>&1)

More From » cron

 Answers
4

sleep does not take the argument in parentheses (like in C), so it should be



* * * * * sleep 10; /var/tmp/myscript.sh


Always test the commands in the system shell before feeding it to cron ;).


[#41780] Sunday, October 24, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
iething

Total Points: 49
Total Questions: 127
Total Answers: 112

Location: Luxembourg
Member since Tue, Jan 25, 2022
2 Years ago
;