So, that would be 10:00:00, 10:01:00, 10:02:00 etc, then 20:00:00, 20:01:00, 20:02:00 etc, then 00:00:00, 00:01:00, 00:02:00 etc, then 10:00:00 etc.
Also, instead of putting everything in the etc/crontab file, you might be better off creating an individual file for each job in the /etc/cron.d drop-in directory. That might give you more options for each job regarding the shell used etc compared to using the /etc/crontab file.
For example, here is the /etc/cron.d/0hourly file:
# Run the hourly jobs
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
01 * * * * root run-parts /etc/cron.hourly
Edit: and I see that @xabbu has also noticed the unusual scheduling of the job while I was typing this.
# Run the hourly jobs
SHELL=/bin/bash
PATH=/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# MAILTO=root
0 * * * * root CachingMergerfs
The PATH is just so you don’t need to use a absolut path for your script/program. If you want every hour at :00 use 0.
Of course you can do
# Run the hourly jobs
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
# MAILTO=root
0 * * * * root /usr/local/bin/CachingMergerfs
If your Path is just PATH=/usr/local/bin and CachingMergerfs is a Shell script, you would need to use an absolut path for all programs that are not in /usr/local/bin and are called in this script.
Drop in files in /etc/cron.d/ are just another way if you want a cleaner system crontab. And you can set other environment variables, but it is often not needed.
The author of the script says the cron job needs to be run as root, but I’m wondering if it might work if I set the user to donatus as well?
The script works fine if I do it from a terminal, i.e. just type CachingMergerfs.
Is there a way that I can verify that it’s executing the script? Because until now I’m just looking at the System Monitor → Processes in the GUI if the program that the script shall execute is running (which doesn’t).
And systemctl status cronie said:
Jan 06 12:00:00 Morpheus CROND[27268]: (root) CMD (CachingMergerfs)
EDIT: It’s working! If I set user to donatus it works
It is yes. And it seems to work as normal user with cron.d
Executing it from terminal works without sudo
No, I don’t think so. Would it help if I provide the script itself? (I’m still learning a lot, not very familiar with scripting/cron)
I can now also see (If run as donatus), that the program/tool the script is supposed to execute is indeed running So I think it actually works now! Also systemctl status CachingMergerfs is now printing the script itself (It basically fires an rsync job and is shown now in the status of cron) and rsync is running as well
Not sure why it was not working in the beginning, maybe it was just a combination of the cron schedule and looking in the wrong place for messages form the program.