You are not logged in.

#1 2010-10-26 10:03:37

zenlord
Member
From: Belgium
Registered: 2006-05-24
Posts: 1,221
Website

working with cron

Hi,

Not per se a newbie, but since this is a newbie question, I'll file it in here:

I know the wiki tells me to use 'crontab -e'  to set up new rules, but I'm kind of confused with the directories (and their contents) /etc/cron.daily, /etc/cron.hourly etc.

In those directories, there are scripts (adjtime in hourly etc.), so presuming that those scripts are run at their respective timings, wouldn't it be easier to add a bash script in the folders than to fiddle with 'crontab -e'? I'm asking because my vi-skills are close to zero and I find it very hard to navigate in vi-style (I probably should learn how to do this, but my question is still valid I suppose...)

THX!

Offline

#2 2010-10-26 10:11:37

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: working with cron

from the manual:

Generally the -e option is used to edit your crontab.  crontab will use the editor specified by your EDITOR or VISUAL environment variable (or /usr/bin/vi) to edit the crontab.

crontab  doesn't  provide  the  kinds  of  protections that programs like visudo do against syntax errors and simultaneous edits.  Errors won't be detected until crond reads the crontab file.  What  crontab does is provide a mechanism for users who may not themselves have write privileges to the crontab folder to nonetheless install or edit their crontabs.  It also  notifies  a  running  crond daemon of any changes to these files.

So if you set EDITOR to (for example) /usr/bin/nano then that's the editor that will be used.
The other bits quoted above explain why it's useful to use it. In a single user system you could restart the daemon - but on multi-user systems that's a no go. However once you get a little practice with crontab, it becomes the easiest way to do this (IMHO).


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#3 2010-10-26 10:20:01

zenlord
Member
From: Belgium
Registered: 2006-05-24
Posts: 1,221
Website

Re: working with cron

OK, fair enough.

So we are encouraged to set our own cron-jobs via crontab and make it possible for packages to install cronjobs automagically - is this why we are having two parallel 'systems' to add a cronjob (crontab and scripts in the folders)?

Offline

#4 2010-10-26 10:33:27

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: working with cron

Well tbh my reason for posting the above was to show how you can change your crontab editor, and I'm generally guessing about this next bit.

I think you're right that that's the reason for those dirs - it also means that an error in a package won't trash the crontab file, and thus stop all the other items from running.

It looks like the scripts in those dirs will be run by root, so you may want to be careful what scripts go in there - you may not want one that deletes files for example as an error could have unfortunate consequences. This is why I find it easier to use crontab as I don't have to worry about what may happen if my script runs as root (scripts that I want to run as root may be a different matter but atm I don't have any - I may used to have had some, I don't remember off the top of my head). But obviously some might find it easier to bung stuff into those dirs.

One question, are they an Archism? I haven't used many other distros and don't recall seeing them before Arch - though I knew far less of my system generally then so could have missed them.


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#5 2010-10-26 15:28:46

sausageandeggs
Member
Registered: 2009-12-05
Posts: 66

Re: working with cron

skanky wrote:

One question, are they an Archism? I haven't used many other distros and don't recall seeing them before Arch - though I knew far less of my system generally then so could have missed them.

Well Linux Mint (and hence Ubuntu I guess) has the cron.* folders, so prob not an Archism.

Offline

#6 2010-10-26 15:38:34

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: working with cron

sausageandeggs wrote:
skanky wrote:

One question, are they an Archism? I haven't used many other distros and don't recall seeing them before Arch - though I knew far less of my system generally then so could have missed them.

Well Linux Mint (and hence Ubuntu I guess) has the cron.* folders, so prob not an Archism.

Thanks. smile


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

Board footer

Powered by FluxBB