• Post Reply Bookmark Topic Watch Topic
  • New Topic

cron job not running  RSS feed

 
kri shan
Ranch Hand
Posts: 1489
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
test.sh prints value test during ./test.sh. But test.cron does not print any value.

cd /a/b/
test.sh
-------

#!/bin/bash
echo "test"


cd etc/cron.daily/
test.cron
----------
#!/bin/sh
2 5 * * * /a/b/test.sh
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depending on your setup, cron will either log to a specific location (meaning stdout/stderr --> log file), or more commonly, email the stdout/stderr results to you. If you are not getting either, then it is probably not configured for either.

Anyway, and only because I am too lazy to debug cron configurations / setups, why not just route the stdout/stderr to a log file (or email the results) directly in the script?

Henry
 
Andrew Polansky
Ranch Hand
Posts: 310
18
Linux MS IE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your test.cron file is invalid. You are using the format for crontab file, while you want to use a simple script file in cron.daily folder. Simply put the test.sh file in your /etc/cron.daily/ folder and it will work. Note the Henry's comments about the output.

Alternatively, you can enter the content of your test.cron file into the crontab file. Simply enter the "crontab -e" command to edit it.
 
Tim Holloway
Saloon Keeper
Posts: 18789
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:Depending on your setup, cron will either log to a specific location (meaning stdout/stderr --> log file), or more commonly, email the stdout/stderr results to you. If you are not getting either, then it is probably not configured for either.

Anyway, and only because I am too lazy to debug cron configurations / setups, why not just route the stdout/stderr to a log file (or email the results) directly in the script?

Henry


Log files for cron are often found under the /var/log/cron directory (e. g. /var/log/cron). Athough if your system is infected with systemd, you may have to look in the binary journal.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!