Sunday, September 28, 2014

cron - crontab day of month not working



My crontab is working even too much: today is the 21th (of november, 2015) and both of these lines gets executed. I really cannot figure out why.




* * 1 * 0,6 echo "test in dom" >> /opt/testweekend
* * * * 0,6 echo "test" >> /opt/testweekend

Answer



Today, 21 Nov 2015, is a Saturday, so the second is clearly eligible to run. But the first is, also; the man page for crontab(5) says that




Note: The day of a command's execution can be specified in the
following two fields — 'day of month', and 'day
of week'. If both fields are restricted (i.e., do not contain the "*" character), the command will be run when

either field matches the current time. For example,
30 4 1,15 * 5 would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday.




Thus your first entry will run every minute of every Saturday and Sunday, and every minute of the first of every month.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...