But for some reasons I have to kick off the weekly backup manually. Any idea why it doesn't work?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 3 times in total.
Reason:Topic automatically closed 6 months after creation. New replies are no longer allowed.
In the meantime I created a subfolder /etc/cron.minutely to test the execution of a simple logger script (Don't want to wait one week every time ). I see that cron starts - but no script in /etc/cron.minutely is executed. The script hello writes a message into /var/log/syslog - but there is no message written every minute
obelix log # cat /etc/cron.minutely/0anacron
#!/bin/sh
#
# anacron's cron script
#
# This script updates anacron time stamps. It is called through run-parts
# either by anacron itself or by cron.
#
# The script is called "0anacron" to assure that it will be executed
# _before_ all other scripts.
test -x /usr/sbin/anacron || exit 0
anacron -u cron.minutely
obelix log # 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 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 )
* * * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.minutely )
#
Try full path to logger? And always include in your cron scripts a feature to capture stdout and stderr into a logfile, else you won't know what is going wrong. As in example below:
Dec 3 18:47:01 obelix CRON[7704]: (root) CMD (test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.minutely ))
every minute - but neither an update is written in /var/log/hello.log (note the -xv flags for bash) nor in /tmp/hello. For some reasons the script is not called by cron - even it has 755 as root.root Do I have to register the script somehow?
framp wrote:For some reasons the script is not called by cron - even it has 755 as root.root Do I have to register the script somehow?
I'm using cron.hourly and cron.weekly, and just put a script in those folders, 755 it and is owned by root. No need to register it, so from all info you give it should work. You might try adding your script to cron.hourly folder, just to test if for whatever reason that does work...
That's what I'll do. I hope I can speed up the test just by modifying the time. Frankly I don't want to wait one hour for every test . I'll keep you posted
I just copied the script from /etc/cron.minutely into /etc/cron.hourly and then the script is called successfully. I now know how to debug and log the sysout and syserr of scripts invoked by cron and will continue further debugging. Thx for your help and hints.
Just an update on this issue: I detected cron is configured to invoke the weekly scripts at around 6 am in the morning. Because it's my desktop and I usually sleep at this time my system is down and cron will not invoke the weekly scripts. That's different on openSuSE where the check is done every 15 mins for every scheduled task (daily, weekly and monthly). I just migrated form openSuSE to Mint because I like Mint much more than openSuSE but that's an annoying feature of Mint/ubuntu . I changed the cron defs so the weekly scripts are called at 8 pm when I'm usually online and it works now