You are not logged in.

#1 2013-07-17 15:16:53

lmello
Member
From: Brazil
Registered: 2012-11-06
Posts: 300

Confused about cronie

I'm a bit confused about the cronie package in Arch. Am I supposed to configure my crontab with 'crontab -e' - the traditional approach to me since I run Slackware also - or should I hack the /etc/cron.d directory? How does it work? Because a file named 0hourly is put there and I figured that it's supposed to run what's in /etc/cron.hourly (which by default has a script to call anacron).


Fundamental Axiom of the Universe (aka Murphy's Law): Whatever can go wrong, will go wrong.
First Digital Deduction: Nothing obeys Murphy's Law so well as computers.
Second Digital Deduction: Everything go wrong at least once.
Third Digital Deduction: Things go wrong even when there's absolutely no possibility of anything go wrong.

Offline

#2 2013-07-17 16:12:40

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: Confused about cronie

Ideally, you shouldn't put scripts in cron.d. It is meant for the packages to install their scripts there.

You should either put your scripts in cron.{hourly,daily,monthly,weekly} or use "crontab -e".

Offline

#3 2013-07-17 16:41:06

lmello
Member
From: Brazil
Registered: 2012-11-06
Posts: 300

Re: Confused about cronie

x33a wrote:

You should either put your scripts in cron.{hourly,daily,monthly,weekly} or use "crontab -e".

Isn't this 'or' an 'and'? Can I just put system-wide scripts there and not run 'crontab -e' as root?


Fundamental Axiom of the Universe (aka Murphy's Law): Whatever can go wrong, will go wrong.
First Digital Deduction: Nothing obeys Murphy's Law so well as computers.
Second Digital Deduction: Everything go wrong at least once.
Third Digital Deduction: Things go wrong even when there's absolutely no possibility of anything go wrong.

Offline

#4 2013-07-17 16:48:39

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: Confused about cronie

I am not sure about the contents of cronie's root crontab.

But with dcron, you can just drop the scripts inside the directories I mentioned and they are run accordingly and no change is required with crontab -e.

Here's the contents of my dcron root crontab:

@hourly         ID=sys-hourly   /usr/bin/run-cron /etc/cron.hourly
@daily          ID=sys-daily    /usr/bin/run-cron /etc/cron.daily
@weekly         ID=sys-weekly   /usr/bin/run-cron /etc/cron.weekly
@monthly        ID=sys-monthly  /usr/bin/run-cron /etc/cron.monthly

I believe that cronie's should be similar.

Offline

#5 2013-07-17 17:31:49

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: Confused about cronie

Cronie separates the anacron functionality from the root crontab.  So this is the /etc/anacrontab:

# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=""
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22

#period in days   delay in minutes   job-identifier   command
1	5	cron.daily		nice run-parts /etc/cron.daily
7	25	cron.weekly		nice run-parts /etc/cron.weekly
@monthly 45	cron.monthly		nice run-parts /etc/cron.monthly

@Imello, for your user, you should be using "crontab -e" and for root you should also use "crontab -e".  If you want to use anacron at in interval that fits within the existing setup (that is, daily/weekly/monthly) then you should use the /etc/cron.{daily,weekly,monthly}.  As I understand it, the difference between cron and anacron is that cron will run something at the specified intervals if the machine is on, while anacron will check to see if the given interval has been run at the appropriate time.  If it has been missed, it will run it.

So you should definitely be using "crontab -e" or /etc/cron.{daily,weekly,monthly}.

With the /etc/cron.hourly directory, you could use that, but it is actually just run as an hourly regular cronjob, not by anacron like the others.  I presume this is because it is a regular enough interval that it will likely be run fairly consistently.

Offline

#6 2013-07-18 17:34:27

lmello
Member
From: Brazil
Registered: 2012-11-06
Posts: 300

Re: Confused about cronie

@Imello, for your user, you should be using "crontab -e" and for root you should also use "crontab -e".

So you should definitely be using "crontab -e" or /etc/cron.{daily,weekly,monthly}.

Thanks, I think I get it: can I put my scripts on these folders and use 'crontab -e' for like @x33a's just 'to make sure'?


Fundamental Axiom of the Universe (aka Murphy's Law): Whatever can go wrong, will go wrong.
First Digital Deduction: Nothing obeys Murphy's Law so well as computers.
Second Digital Deduction: Everything go wrong at least once.
Third Digital Deduction: Things go wrong even when there's absolutely no possibility of anything go wrong.

Offline

#7 2013-07-19 05:31:51

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: Confused about cronie

If you want to execute a script at a particular time, you should use crontab -e. If you just want the script to execute regardless of the time, you should drop it in the appropriate folder. And no, you don't need to do anything else just "to make sure".

Anyway to troubleshoot any problem with the script, you should check the cron logs.

Last edited by x33a (2013-07-19 05:32:41)

Offline

#8 2013-07-19 09:12:56

lmello
Member
From: Brazil
Registered: 2012-11-06
Posts: 300

Re: Confused about cronie

Thanks folks!


Fundamental Axiom of the Universe (aka Murphy's Law): Whatever can go wrong, will go wrong.
First Digital Deduction: Nothing obeys Murphy's Law so well as computers.
Second Digital Deduction: Everything go wrong at least once.
Third Digital Deduction: Things go wrong even when there's absolutely no possibility of anything go wrong.

Offline

#9 2013-07-21 00:50:49

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,152

Re: Confused about cronie

WonderWoofy wrote:

With the /etc/cron.hourly directory, you could use that, but it is actually just run as an hourly regular cronjob, not by anacron like the others.  I presume this is because it is a regular enough interval that it will likely be run fairly consistently.

cron is responsible for running anacron via cron.hourly. So it would be circular for anacron to run stuff in cron.hourly which would run anacron which would run stuff in cron.hourly...

I actually have a backup script in cron.hourly. I do that because I want to check 2 conditions: existence of external drive for backup and time since last run. That it ran in 2 hours ago does me no good if the drive wasn't connected. Likewise, I don't want it to run again if it was done half an hour ago and then I attach the backup.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

Board footer

Powered by FluxBB