SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I wonder what's the orthodox way to handle cronjobs on a Slackware machine. Say I have to run a weekly backup script. I'd edit crontab using crontab -e like this, for example:
Code:
15 3 * * 0 root /root/backup.sh
So the script would run every Sunday at 3:15 AM.
Now in Slackware, there's a series of cron.daily, cron.weekly etc. directories, containing each a series of scripts, to be run at respective intervals.
I wonder if an orthodox way of running my script would be to move and rename it to, say, /etc/cron.weekly/backup... and then leave it there.
I'd be grateful for the relevant piece of information/documentation about the subject.
I think the /etc/cron.* directories are merely conveniences. They make configuration somewhat simpler, but at the cost of fine-granular control. Also, they are not available to non-root users.
cron.* is called by /etc/crontab which gets sourced by crond. The only downside I can see using them is that they are run at a fixed time and in sequencial order. So if your first job in cron.daily takes two hours all the other jobs need to wait. Good or bad. But I don't want my cronjobs to hog the system. I would use the cron.* directories for system specific jobs like backup (your use case) or update checking or removing stuff, logrotation etc. And user owned jobs (crontab -e) for special needs like cleaning after my auto compilation or similar.
The default root crontab (/var/spool/cron/crontabs/root) uses /usr/bin/run-parts to execute scripts in the /etc/cron.* directories.
Code:
bash-4.2# crontab -l
# If you don't want the output of a cron job mailed to you, you have to direct
# any output to /dev/null. We'll do this here since these jobs should run
# properly on a newly installed system. If a script fails, run-parts will
# mail a notice to root.
#
# Run the hourly, daily, weekly, and monthly cron jobs.
# Jobs that need different timing may be entered into the crontab as before,
# but most really don't need greater granularity than this. If the exact
# times of the hourly, daily, weekly, and monthly cron jobs do not suit your
# needs, feel free to adjust them.
#
# Run hourly cron jobs at 47 minutes after the hour:
47 * * * * /usr/bin/run-parts /etc/cron.hourly 1> /dev/null
#
# Run daily cron jobs at 4:40 every day:
40 4 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null
#
# Run weekly cron jobs at 17:30 on the first day of the week:
30 17 * * 0 /usr/bin/run-parts /etc/cron.weekly 1> /dev/null
#
# Run monthly cron jobs at 4:20 on the first day of the month:
20 4 1 * * /usr/bin/run-parts /etc/cron.monthly 1> /dev/null
Usually I change the times in the default crontab and put my backup scripts in /etc/cron.weekly. Works for me.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.