Hi, What is the correct way to edit the system crontab file? I know I've done it in the past, because I have /etc/crontab which contains all my backup routines. Is it permissible to edit it with any editor (eg. vim, kate), as root? I've tried issuing ~ # crontab -e but that just creates a new, blank file. I think I'm getting too old for this :( Bob -- Registered Linux User #463880 FSFE Member #1300 GPG-FP: A6C1 457C 6DBA B13E 5524 F703 D12A FB79 926B 994E openSUSE 11.3, Kernel 2.6.34.12-desktop, KDE 4.4.4 Intel Core2 Quad Q9400 2.66GHz, 8GB DDR RAM, nVidia GeForce 9600GT -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Hi,
What is the correct way to edit the system crontab file? I know I've done it in the past, because I have /etc/crontab which contains all my backup routines. Is it permissible to edit it with any editor (eg. vim, kate), as root?
I've tried issuing
~ # crontab -e
but that just creates a new, blank file.
I think I'm getting too old for this :(
Bob
IIRC (been a very long time) it can be edited manually. However, since you are using KDE, take a look at Personal Settings/Advanced/Task Schedule; that will create the crontab for you. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Tuesday 17 Aug 2010 18:32:26 dwgallien wrote:
Hi,
What is the correct way to edit the system crontab file? I know I've done it in the past, because I have /etc/crontab which contains all my backup routines. Is it permissible to edit it with any editor (eg. vim, kate), as root?
I've tried issuing
~ # crontab -e
but that just creates a new, blank file.
I think I'm getting too old for this :(
Bob
IIRC (been a very long time) it can be edited manually. However, since you are using KDE, take a look at Personal Settings/Advanced/Task Schedule; that will create the crontab for you.
That only lets me edit my personal crontab. I want to edit the system crontab, as I have some tasks that have to run as root. I'll try editing it manually and see what happens :) Thanks. Bob -- Registered Linux User #463880 FSFE Member #1300 GPG-FP: A6C1 457C 6DBA B13E 5524 F703 D12A FB79 926B 994E openSUSE 11.3, Kernel 2.6.34.12-desktop, KDE 4.4.4 Intel Core2 Quad Q9400 2.66GHz, 8GB DDR RAM, nVidia GeForce 9600GT -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
That only lets me edit my personal crontab. I want to edit the system crontab, as I have some tasks that have to run as root. I'll try editing it manually and see what happens :)
Thanks.
Bob Go grab webmin.
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Tuesday August 17 2010, Bob Williams wrote:
...
... I want to edit the system crontab, as I have some tasks that have to run as root. I'll try editing it manually and see what happens :)
You can simply: % sudo crontab -e
Bob
Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 2010-08-18 00:07, Randall R Schulz wrote:
On Tuesday August 17 2010, Bob Williams wrote:
...
... I want to edit the system crontab, as I have some tasks that have to run as root. I'll try editing it manually and see what happens :)
You can simply:
% sudo crontab -e
That does not edit the system's crontab, but root's crontab. -- Cheers / Saludos, Carlos E. R. (from 11.2 x86_64 "Emerald" GM (Elessar))
On Tuesday August 17 2010, Carlos E. R. wrote:
On 2010-08-18 00:07, Randall R Schulz wrote:
On Tuesday August 17 2010, Bob Williams wrote:
...
... I want to edit the system crontab, as I have some tasks that have to run as root. I'll try editing it manually and see what happens :)
You can simply:
% sudo crontab -e
That does not edit the system's crontab, but root's crontab.
OK. Is there effectively any difference? Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 2010-08-18 01:56, Randall R Schulz wrote:
On Tuesday August 17 2010, Carlos E. R. wrote:
On 2010-08-18 00:07, Randall R Schulz wrote:
You can simply:
% sudo crontab -e
That does not edit the system's crontab, but root's crontab.
OK. Is there effectively any difference?
A lot. Different file, different syntax. See Brian K. White post for a detailed explanation. -- Cheers / Saludos, Carlos E. R. (from 11.2 x86_64 "Emerald" GM (Elessar))
On 8/17/2010 7:56 PM, Randall R Schulz wrote:
On Tuesday August 17 2010, Carlos E. R. wrote:
On 2010-08-18 00:07, Randall R Schulz wrote:
On Tuesday August 17 2010, Bob Williams wrote:
...
... I want to edit the system crontab, as I have some tasks that have to run as root. I'll try editing it manually and see what happens :)
You can simply:
% sudo crontab -e
That does not edit the system's crontab, but root's crontab.
OK. Is there effectively any difference?
Yes.
Ok not good enough or can't fill in the blanks yourself?
Define effectively.
Yes the root jobs will run, and yes being root they can do anything, and
yes on legacy unix that was in fact the definition of the "system" crontab.
Yes there is "effectively" a difference, but the "effect" happens to be
in transparancy/expectations/obfuscation. Few new linux admins will
think to look in root's crontab for typical cron jobs. So if there are
some, you will cause some amount of people writing duplicate or
conflicting jobs in /etc/crontab and discovering the hard way that some
bonehead before them did the unexpected. Also by deviating from most
common documentation, you cause newbies who don't know any better have
unnecessary problems later. Old docs will say "crontab -l >crontab ; vi
crontab ;crontab
On Tuesday 17 Aug 2010 18:32:26 dwgallien wrote:
Hi,
What is the correct way to edit the system crontab file? I know I've done it in the past, because I have /etc/crontab which contains all my backup routines. Is it permissible to edit it with any editor (eg. vim, kate), as root?
I've tried issuing
~ # crontab -e
but that just creates a new, blank file.
I think I'm getting too old for this :(
Bob
IIRC (been a very long time) it can be edited manually. However, since you are using KDE, take a look at Personal Settings/Advanced/Task Schedule; that will create the crontab for you.
That only lets me edit my personal crontab. I want to edit the system crontab, as I have some tasks that have to run as root. I'll try editing it manually and see what happens :)
Thanks.
Bob
Check that again. There should be a radio button for "system cron". Using this option requires running as root. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Tuesday 17 Aug 2010 23:59:21 dwgallien wrote:
On Tuesday 17 Aug 2010 18:32:26 dwgallien wrote:
Hi,
What is the correct way to edit the system crontab file? I know I've done it in the past, because I have /etc/crontab which contains all my backup routines. Is it permissible to edit it with any editor (eg. vim, kate), as root?
I've tried issuing
~ # crontab -e
but that just creates a new, blank file.
I think I'm getting too old for this :(
Bob
IIRC (been a very long time) it can be edited manually. However, since you are using KDE, take a look at Personal Settings/Advanced/Task Schedule; that will create the crontab for you.
That only lets me edit my personal crontab. I want to edit the system crontab, as I have some tasks that have to run as root. I'll try editing it manually and see what happens :)
Thanks.
Bob
Check that again. There should be a radio button for "system cron". Using this option requires running as root.
And that's what I don't want to do - log into a graphical environment as root just to be able to edit a small text file. I'm looking for a CLI solution, and Brian's replies have given me that. Bob -- Registered Linux User #463880 FSFE Member #1300 GPG-FP: A6C1 457C 6DBA B13E 5524 F703 D12A FB79 926B 994E openSUSE 11.3, Kernel 2.6.34.12-desktop, KDE 4.4.4 Intel Core2 Quad Q9400 2.66GHz, 8GB DDR RAM, nVidia GeForce 9600GT -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 8/18/2010 4:51 AM, Bob Williams wrote:
On Tuesday 17 Aug 2010 23:59:21 dwgallien wrote:
On Tuesday 17 Aug 2010 18:32:26 dwgallien wrote:
Hi,
What is the correct way to edit the system crontab file? I know I've done it in the past, because I have /etc/crontab which contains all my backup routines. Is it permissible to edit it with any editor (eg. vim, kate), as root?
I've tried issuing
~ # crontab -e
but that just creates a new, blank file.
I think I'm getting too old for this :(
Bob
IIRC (been a very long time) it can be edited manually. However, since you are using KDE, take a look at Personal Settings/Advanced/Task Schedule; that will create the crontab for you.
That only lets me edit my personal crontab. I want to edit the system crontab, as I have some tasks that have to run as root. I'll try editing it manually and see what happens :)
Thanks.
Bob
Check that again. There should be a radio button for "system cron". Using this option requires running as root.
And that's what I don't want to do - log into a graphical environment as root just to be able to edit a small text file. I'm looking for a CLI solution, and Brian's replies have given me that.
Bob
To be fair, any menu item that requires root should, and probably already does, use gksudo or similar rather than being directly called like other harmless apps. No one ever advises actually logging in to a full desktop as root any more. Those apps that need root will ask you for the root password right when you run that specific app and it will only apply to that app. You should be able to use the gui just fine, while logged in as a normal user. Even if a given util does not currently use a sudo-alike, you can just edit that menu entry to do so. Personally I'd rather just edit the file directly as you are, but there IS one reason to use a front-end, be it gui or curses or web, which is you can at least count on the front end to always write out a syntactically valid config file. It may or may not do what you want, but it won't make syntax errors that break the file like missing quotes or wrong number of fields in a line etc.. It's safer for most users. -- bkw -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Wednesday 18 August 2010 23:56:36 Brian K. White wrote:
On 8/18/2010 4:51 AM, Bob Williams wrote:
On Tuesday 17 Aug 2010 23:59:21 dwgallien wrote:
On Tuesday 17 Aug 2010 18:32:26 dwgallien wrote:
Hi,
What is the correct way to edit the system crontab file? I know I've done it in the past, because I have /etc/crontab which contains all my backup routines. Is it permissible to edit it with any editor (eg. vim, kate), as root?
I've tried issuing
~ # crontab -e
but that just creates a new, blank file.
I think I'm getting too old for this :(
Bob
IIRC (been a very long time) it can be edited manually. However, since you are using KDE, take a look at Personal Settings/Advanced/Task Schedule; that will create the crontab for you.
That only lets me edit my personal crontab. I want to edit the system crontab, as I have some tasks that have to run as root. I'll try editing it manually and see what happens :)
Thanks.
Bob
Check that again. There should be a radio button for "system cron". Using this option requires running as root.
And that's what I don't want to do - log into a graphical environment as root just to be able to edit a small text file. I'm looking for a CLI solution, and Brian's replies have given me that.
Bob
To be fair, any menu item that requires root should, and probably already does, use gksudo or similar rather than being directly called like other harmless apps.
No one ever advises actually logging in to a full desktop as root any more. Those apps that need root will ask you for the root password right when you run that specific app and it will only apply to that app.
You should be able to use the gui just fine, while logged in as a normal user. Even if a given util does not currently use a sudo-alike, you can just edit that menu entry to do so.
Personally I'd rather just edit the file directly as you are, but there IS one reason to use a front-end, be it gui or curses or web, which is you can at least count on the front end to always write out a syntactically valid config file. It may or may not do what you want, but it won't make syntax errors that break the file like missing quotes or wrong number of fields in a line etc.. It's safer for most users.
On my system, the radio button button referred to by dwgallien only allows me to view the system cron, there is no option to edit it, hence my remark that I would need to login to the gui as root. I guess I could find the Stem Settings entry in the kmenu editor and change that behaviour. I hadn't thought of that... Except there's no submenu to edit :( Bob -- Registered Linux User #463880 FSFE Member #1300 GPG-FP: A6C1 457C 6DBA B13E 5524 F703 D12A FB79 926B 994E openSUSE 11.3, Kernel 2.6.34.12-desktop, KDE 4.5.0 Intel Core2 Quad Q9400 2.66GHz, 8GB DDR RAM, nVidia GeForce 9600GT -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On my system, the radio button button referred to by dwgallien only allows me to view the system cron, there is no option to edit it, hence my remark that I would need to login to the gui as root. I guess I could find the Stem Settings entry in the kmenu editor and change that behaviour. I hadn't thought of that...
Except there's no submenu to edit :(
Bob
"kdesu systemsettings" from a terminal or in krunner (Alt-F2). -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thursday 19 August 2010 18:11:26 dwgallien wrote:
On my system, the radio button button referred to by dwgallien only allows me to view the system cron, there is no option to edit it, hence my remark that I would need to login to the gui as root. I guess I could find the Stem Settings entry in the kmenu editor and change that behaviour. I hadn't thought of that...
Except there's no submenu to edit :(
Bob
"kdesu systemsettings" from a terminal or in krunner (Alt-F2).
Hmm, System Settings comes up OK, but then crashes when I select Task Scheduler. I need to investigate. Thanks for the tip, though. Bob -- Registered Linux User #463880 FSFE Member #1300 GPG-FP: A6C1 457C 6DBA B13E 5524 F703 D12A FB79 926B 994E openSUSE 11.3, Kernel 2.6.34.12-desktop, KDE 4.5.0 Intel Core2 Quad Q9400 2.66GHz, 8GB DDR RAM, nVidia GeForce 9600GT -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 8/17/2010 1:05 PM, Bob Williams wrote:
Hi,
What is the correct way to edit the system crontab file? I know I've done it in the past, because I have /etc/crontab which contains all my backup routines. Is it permissible to edit it with any editor (eg. vim, kate), as root?
I've tried issuing
~ # crontab -e
but that just creates a new, blank file.
I think I'm getting too old for this :(
Bob
crontab -e, as root, edits the root users own crontab (/var/spool/cron/tabs/root) , which on legacy unix systems was the system crontab. You can use that if you want, it will work as expected. On linux, or more correctly, when using vixie-cron on whatever platform, /etc/crontab is the "system" crontab and it has a different syntax than the individual users crontabs. For one thing it has an extra field between the time specs and the command, which is the user the job should run as. They are not simply run as root the way jobs in root's crontab are. Also there is a small prefix (-) you can add to the beginning of a line to tell cron not to write a line to syslog every time it runs that job. You can edit /etc/crontab directly with any editor of your choice at any time and the effects take place immediately when you save the file. No need to restart cron, no need to notify cron or reload the file with the crontab command. You can also create scripts in /etc/cron.d/* and not write any crontab entries in any crontab anywhere. /etc/crontab already includes entries to periodically run any scripts found in those directories. If you need to specify the particular time of day, instead of accepting whenever "nightly" happens to run, then you need to write a crontab entry. If you use crontab -e as a normal user you won't be able to do full backups that way because the jobs will run as that user, who does not have permission to read all files and may not even have permission to write to the backup device. -- bkw -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 2010-08-17 19:57, Brian K. White wrote:
crontab -e, as root, edits the root users own crontab (/var/spool/cron/tabs/root) , which on legacy unix systems was the system crontab. You can use that if you want, it will work as expected.
On linux, or more correctly, when using vixie-cron on whatever platform, /etc/crontab is the "system" crontab and it has a different syntax than the individual users crontabs. For one thing it has an extra field between the time specs and the command, which is the user the job should run as. They are not simply run as root the way jobs in root's crontab are. Also there is a small prefix (-) you can add to the beginning of a line to tell cron not to write a line to syslog every time it runs that job.
You can edit /etc/crontab directly with any editor of your choice at any time and the effects take place immediately when you save the file. No need to restart cron, no need to notify cron or reload the file with the crontab command.
You can also create scripts in /etc/cron.d/* and not write any crontab entries in any crontab anywhere. /etc/crontab already includes entries to periodically run any scripts found in those directories. If you need to specify the particular time of day, instead of accepting whenever "nightly" happens to run, then you need to write a crontab entry.
I'm saving this, it is a nice summary, not so easy to locate that info in the man pages. :-) One note, though: you don't need to edit the file if you want to adjust the time to run since oS 11.2, we have an addition to the scripts: /etc/sysconfig/cron: ## Type: string ## Default: "" # # At which time cron.daily should start. Default is 15 minutes after booting # the system. Example setting would be "14:00". # Due to the fact that cron script runs only every 15 minutes, # it will only run on xx:00, xx:15, xx:30, xx:45, not at the accurate time # you set. DAILY_TIME="" ## Type: integer ## Default: 5 # # Maximum days not running when using a fixed time set in DAILY_TIME. # 0 to skip this. This is for users who will power off their system. # # There is a fixed max. of 14 days set, if you want to override this # change MAX_NOT_RUN_FORCE in /usr/lib/cron/run-crons MAX_NOT_RUN="5"
If you use crontab -e as a normal user you won't be able to do full backups that way because the jobs will run as that user, who does not have permission to read all files and may not even have permission to write to the backup device.
That's something that is missing in linux: the possibility of defining users with roles. A user for backup that may copy any file to a predefined backup destination, but not read them. For example. Of course, we can use sudo to allow someone to start a predefined backup job and a few things more. -- Cheers / Saludos, Carlos E. R. (from 11.2 x86_64 "Emerald" GM (Elessar))
On Tuesday 17 Aug 2010 18:57:18 Brian K. White wrote:
On 8/17/2010 1:05 PM, Bob Williams wrote:
Hi,
What is the correct way to edit the system crontab file? I know I've done it in the past, because I have /etc/crontab which contains all my backup routines. Is it permissible to edit it with any editor (eg. vim, kate), as root?
I've tried issuing
~ # crontab -e
but that just creates a new, blank file.
I think I'm getting too old for this :(
Bob
[...]
You can edit /etc/crontab directly with any editor of your choice at any time and the effects take place immediately when you save the file. No need to restart cron, no need to notify cron or reload the file with the crontab command.
[...] Brian, many thanks for that clear, lucid and helpful answer. Bob -- Registered Linux User #463880 FSFE Member #1300 GPG-FP: A6C1 457C 6DBA B13E 5524 F703 D12A FB79 926B 994E openSUSE 11.3, Kernel 2.6.34.12-desktop, KDE 4.4.4 Intel Core2 Quad Q9400 2.66GHz, 8GB DDR RAM, nVidia GeForce 9600GT -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On 2010-08-17 19:57, Brian K. White wrote:
You can edit /etc/crontab directly with any editor of your choice at any time and the effects take place immediately when you save the file. No need to restart cron, no need to notify cron or reload the file with the crontab command.
Now that I remember. The proper way is not editing /etc/crontab, but adding a file in /etc/cron.d/, which has the same syntax. This way, if there is an update/upgrade, we are safe even if it is overwritten.
You can also create scripts in /etc/cron.d/* and not write any crontab entries in any crontab anywhere.
That. You were too concise ;-) If I read "man cron" correctly, /etc/cron.d/ is read directly by the daemon every minute. However, the suse script "/usr/lib/cron/run-crons" checks every 15 minutes to run, if needed, the scripts in cron.hourly, cron.daily, cron.weekly, and cron.monthly. -- Cheers / Saludos, Carlos E. R. (from 11.2 x86_64 "Emerald" GM (Elessar))
participants (6)
-
Bob Williams
-
Brian K. White
-
Carlos E. R.
-
dwgallien
-
Michael S. Dunsaavage
-
Randall R Schulz