Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
Where did you find/read about the option to add jobs to /etc/crontab file ?
It's the directory /etc/cron.daily or /etc/cron.hourly or whichever you want to put the script into
so that executes at desired intervals.
Check the /etc/cron.daily files within and make your script as that inside.
Put your script there and it will run (presuming service crond is running?)
Another way of doing it is edit the crontab file from Root account
with: crontab -e
and putting the line for executing your script at desired time/intervals.
Where did you find/read about the option to add jobs to /etc/crontab file ?
I don't remember - it's the way I've always done it. For years. And it has worked ever since. Simplest method of all, IMHO.
Quote:
Originally Posted by lithos
Another way of doing it is edit the crontab file from Root account
with: crontab -e
and putting the line for executing your script at desired time/intervals.
Yea, but in effect, that does nothing else than editing /etc/crontab. [EDIT: Yes, it does something else: It edits user root's crontab, rather than the global one.] So why do it more complicated than necessary? Why not directly edit the config file?
Yea, but in effect, that does nothing else than editing /etc/crontab. So why do it more complicated than necessary? Why not directly edit the config file?
Have you tried to run command:
Code:
crontab -l
what does it show you ?
Mine is:
Code:
root@~#>crontab -l
# This set of options gives you additonal mail options
# If any dont apply to you, please remove from list.
#!mail(yes),noticenotrun(yes)
# All mails will be sent to root
#!mailto(root)
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin
# Run-parts
01 * * * * run-parts /etc/cron.hourly
02 0 * * * run-parts /etc/cron.daily
22 0 * * 0 run-parts /etc/cron.weekly
42 0 1 * * run-parts /etc/cron.monthly
# * */8 * * * htpdate -s -l www.linux.org
# * */6 * * * hwclock --systohc
And that's logical, in a way, because I didn't create a crontab for the root user, only the global, non-user-specific one that was automatically created during the system setup.
Quote:
Originally Posted by lithos
And if you look at your file: /etc/crontab ?
Then I see a list of all the system-wide cron jobs, plus the generic cron.hourly, cron.daily etc:
Can you please tell me the difference now (besides the Root's crontab is different than /etc/crontab, because ROOT runs some scripts) ?
The difference is that one is user-specific by design (albeit for root), the other isn't. That's why, for example, the system-wide crontab has a field for each cron job that specifies the user under which the job shall execute, while the user-specific crontabs don't have that field.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.