I hope I am asking this question correctly. I am trying to run all jobs that are setup on my server, by nano /etc/crontab I see the list of:

# m h dom mon dow user  command
27 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
58 15    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
0 15    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
20 15    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#

Is it possible to execute crontab to kick off all these jobs, or force them to run?

I am trying to confirm they are actually running.

up vote 13 down vote accepted

If you want to check if they are executed, use:

grep -i cron /var/log/syslog
  • 1
    To test anacron jobs, try this: echo '20141201' > /var/spool/anacron/cron.monthly; anacron -n -f cron.monthly;. There are naming constraints on the scripts under /etc/cron.*. You might also want to check if run-parts is finding your script: run-parts --test /etc/cron.monthly – TrinitronX Jan 22 '15 at 9:02

Just do what cron does.

  • run-parts -v /etc/cron.daily
  • run-parts -v /etc/cron.weekly
  • etc

-v prints the script names before they are run

If you would like to just check that cron is running, you can do the following:

service cron status

This question is really about anacron, which runs these cycled cron jobs.

First, make sure that your anacrontab file has valid syntax. If you see nothing, then it's fine:

/usr/sbin/anacron -T

Next, you can run all of the scripts that will run hourly, daily, weekly and monthly. This could be a lot, so have a look in /etc/cron.{hourly|daily|weekly|monthly} to see what's going to happen. To run them all:

sudo su -
cd / && run-parts --report /etc/cron.hourly
cd / && run-parts --report /etc/cron.daily
cd / && run-parts --report /etc/cron.weekly
cd / && run-parts --report /etc/cron.monthly

Finally see if anacron's scheduling system is working correctly. You can do this with:

/usr/sbin/anacron -n -f cron.monthly

(-n means Run jobs now, -f means force, ignoring timestamps). That will run the monthly jobs. It will run silently in the background, and you will receive an email when the job is done. There will be a random delay before the job starts, which is specified in the delay column in anacrontab.

You can see what's happening using:

grep monthly /var/log/syslog

You should also be able to cause anacron to run any of the cycles by doing something like this:

echo "20160101" | cat > /var/spool/anacron/cron.monthly
/usr/sbin/anacron cron.monthly

This enters a very old date into the spool file. That tells anacron that the monthly job was last run more than a month ago, and it will schedule it to run now or shortly.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.