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.
If you want to check if they are executed, use:
Just do what cron does.
run-parts -v /etc/cron.daily
run-parts -v /etc/cron.weekly
-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:Check log messages from
cron
withjournalctl
. See hereThis 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: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:Finally see if anacron's scheduling system is working correctly. You can do this with:
(
-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 inanacrontab
.You can see what's happening using:
You should also be able to cause anacron to run any of the cycles by doing something like this:
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.