linux - Can anybody tell me, why some of my cronjobs were never executed? -


i have following cronjobs in crontab:

0  22 *   *    1-6 /root/sbin/mysqlbackup --conf-dir=/root/etc/backup --source=monitoringserver --set-name=$(date +"\%a")                                             2>&1 | mail -s "backup /monitoringserver" it@example.com 0  22 *   *    0   [ "`date +\%d`" -gt 7 ] && /root/sbin/mysqlbackup --conf-dir=/root/etc/backup --source=monitoringserver --set-name=woche$((($(date +\%-d)-1)/7+1)) 2>&1 | mail -s "backup /monitoringserver" it@example.com 0  22 *   2-12 0   [ "`date +\%d`" -lt 8 ] && /root/sbin/mysqlbackup --conf-dir=/root/etc/backup --source=monitoringserver --set-name=$(date +"\%b")                  2>&1 | mail -s "backup /monitoringserver" it@example.com 0  22 *   1    0   [ "`date +\%d`" -lt 8 ] && /root/sbin/mysqlbackup --conf-dir=/root/etc/backup --source=monitoringserver --set-name=$(date +"\%y")                  2>&1 | mail -s "backup /monitoringserver" it@example.com 

whereas first line should generate backup every monday till saturday (works). second line should generate backup every sunday using week of month name, except first week (works). third line should executed every first sunday of months february till december (does not work). last line should executed every first sunday of year (unknown if called).

everything seems right me. can tell me why third line not work?

update

✓ root@mirror ~$  echo $(date +"%b"); september ✓ root@mirror ~$  [ "`date +%d`" -lt 8 ] && echo "test" test ✓ root@mirror ~$  echo "`date +%d`" 02 

update

no mail sent on august, 7th (firs sunday of last month). means if job have been executed there had @ least empty mail?

update

/root/sbin/mysqlbackup --conf-dir=/root/etc/backup --source=monitoringserver --set-name=$(date +"\%b") 

performs using sh shell (which used cron default) , using bash shell (which configured @ beginning of crontab).

19 8 * 2-12 5 [ "`date +\%d`" -lt 8 ] && echo $(date +"\%b") 2>&1 | mail -s "backup /monitoringserver" it@example.com 

performed well, too. mail recieved containing month's name.

the syntax correct. cron must have triggered execution line 3 on aug 7.

and yes, you should have received email on aug 07, independent of outcome (and existence) of backup script.

if did not not receive email, possible reasons are:

  • cron down (or entire machine was)
  • you configured bad shell cron
  • the mail service down.

i'd check syslogs cron execution, email submission, , execution of mysqlbackup.


Comments