I have a computer that seems to run the cron jobs sometimes. When I monitor the syslog, I can see the jobs mentioned, but the results of the commands are not visible. How do I fix this?
Version of this box:
username:/etc$ uname -rvp
4.13.0-32-generic #35~16.04.1-Ubuntu SMP Thu Jan 25 10:13:25 UTC 2018 i686
The /etc/crontab
file contents (complete with my notes):
username:/etc$ cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m = minute
# h = hour (24-hour)
# dom = day of month
# mon = month (numeric)
# dow = day of week (sunday is 0, monday is 1, saturday is 6)
# user = user
# command = yep
# * = blank or null entry or wildcard
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
#25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
#47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
#52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
01 18 * * 1 root /sbin/shutdown -h now
00 20 * * 1 root /sbin/shutdown -h now
01 18 * * 2 root /sbin/shutdown -h now
00 20 * * 2 root /sbin/shutdown -h now
01 18 * * 3 root /sbin/shutdown -h now
00 20 * * 3 root /sbin/shutdown -h now
01 18 * * 4 root /sbin/shutdown -h now
00 20 * * 4 root /sbin/shutdown -h now
01 18 * * 5 root /sbin/shutdown -h now
00 20 * * 5 root /sbin/shutdown -h now
01 16 * * 6 root /sbin/shutdown -h now
00 20 * * 6 root /sbin/shutdown -h now
## This is a test entry.
45 10 * * * root /usr/bin/notify-send 'Cronjob Test Message' 'This is a cronjob test message.'
46 10 * * 1 root /usr/bin/notify-send 'Cronjob Monday Test Message' ' This is Mondays cronjob test message.'
20 11 * * * root /usr/bin/notify-send 'Test' 'Message goes here.'
#51 11 * * 4 root shutdown -h now
# This line is the last line, be sure to terminated this line with a new line.
Please notice I have various tests going on in there. I realize this is confusing, so I am going to simplify the /etc/crontab
file for easier troubleshooting. This is my new /etc/crontab
troubleshooting file:
username:/etc$ cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
56 11 * * * root /usr/bin/notify-send 'Test' 'Message goes here.'
Now, I watch my syslog:
username:/etc$ /usr/bin/sudo /usr/bin/tail /var/log/syslog -f
Jan 29 10:58:31 hostname dbus[730]: [system] Successfully activated service 'org.freedesktop.timedate1'
Jan 29 10:58:31 hostname systemd[1]: Started Time & Date Service.
Jan 29 11:10:01 hostname cron[759]: (*system*) RELOAD (/etc/crontab)
Jan 29 11:10:01 hostname CRON[3240]: (root) CMD (/usr/bin/notify-send 'Test' 'Message goes here.')
Jan 29 11:17:01 hostname CRON[3283]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Jan 29 11:19:01 hostname cron[759]: (*system*) RELOAD (/etc/crontab)
Jan 29 11:20:01 hostname CRON[3314]: (root) CMD (/usr/bin/notify-send 'Test' 'Message goes here.')
Jan 29 11:34:35 hostname crontab[3386]: (root) BEGIN EDIT (root)
Jan 29 11:35:46 hostname crontab[3386]: (root) END EDIT (root)
Jan 29 11:55:01 hostname cron[759]: (*system*) RELOAD (/etc/crontab)
Jan 29 11:56:01 hostname cron[759]: (*system*) RELOAD (/etc/crontab)
Jan 29 11:56:01 hostname CRON[3537]: (root) CMD (/usr/bin/notify-send 'Test' 'Message goes here.')
The last line says at 11:56:01 it ran the command /usr/bin/notify-send
but no pop-up message was displayed.
If I run that exact (copy & paste) command from a terminal, preceeded with /usr/bin/sudo
the popup will appear.
username:/etc$ /usr/bin/sudo /usr/bin/notify-send 'Test' 'Message goes here.'
If I run that exact (copy & paste) command from a terminal as the normal user logged in, the popup will appear.
username:/etc$ /usr/bin/notify-send 'Test' 'Message goes here.'
What gives?