0

I have a cron job that is supposed to execute a bash script. I have confirmed the bash script does work as the cron job works properly on my local machine.

However the cron job does not appear to be firing on a remote machine that I have access to. As a test I am doing a touch command. My cron job is as follows:

# Edit this file to introduce tasks to be run by cron.
# 
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# 
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# 
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# 
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# 
# For more information see the manual pages of crontab(5) and cron(8)
# 
# m h  dom mon dow   command
21 12 * * * /usr/bin/touch /home/aidan/test.txt

This cron job should create a test.txt file in "/usr/bin/touch". However, it appears that it is not firing at all.

To debug I have looked at "/var/log/syslog" using the following 2 commands:

  1. sudo cat /var/log/syslog | grep -w 'cron' In this command I am getting the following output:
Dec 13 20:21:01 onecup cron[1628]: (aidan) RELOAD (crontabs/aidan)
  1. sudo grep CRON /var/log/syslog. In this command I am getting the following output:
Dec 13 17:17:01 onecup CRON[1060280]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Dec 13 18:17:01 onecup CRON[1120928]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Dec 13 19:17:01 onecup CRON[1180117]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Dec 13 20:17:01 onecup CRON[1238901]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)

Notice, that in this command the cron job does not appear at all.
My expectation is that the CMD should appear.

In short it appears the cronjob is reloading but never actually firing. Does anyone have any ideas?

Also, note I did see this here: https://stackoverflow.com/questions/60842683/cron-not-running-tasks-ubuntu-18-04.

It did not fix the issue.

7
  • @steeldriver I just double checked. If I do: sudo cat /var/log/syslog | grep -w 'CRON', I get: Dec 13 22:17:01 onecup CRON[1372772]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) So I don't even get any record of the job even reloading. Dec 13, 2022 at 22:35
  • Oops sorry I didn't see you'd already checked both cases. Does the remote system have either of /etc/cron.allow or /etc/cron.deny files? Dec 13, 2022 at 22:41
  • @steeldriver all good! It does not have either of /etc/cron.allow or /etc/cron.deny files Dec 13, 2022 at 23:11
  • ... it seems odd that there appear to be no cron.hourly log entries around your crontab entry's 12:21 timespec (no Dec 13 12:17:01 or Dec 13 13:17:01 for example) Dec 14, 2022 at 0:46
  • The log will usually say this but have you tried putting a new line after the command and then seeing if it runs. Dec 14, 2022 at 1:56

1 Answer 1

0

I found the issue: The machine is operating in the UTC zone, and I'm in the PST zone. So the cron job did not execute at the expected local time.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .