You are not logged in.

#26 2010-01-22 20:33:59

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: Cronwhip - no more missed cronjobs

raymboard wrote:

If I set a daily cron job and left the computer turned off for a week then when I turned it back on would the cron job run 7 times?

Only if you run cronwhip 7 times. wink


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#27 2010-01-22 20:51:19

raymboard
Member
Registered: 2010-01-22
Posts: 61

Re: Cronwhip - no more missed cronjobs

And what if I ran cronwhip 8 times?

And am I really supposed to put brackets in /etc/rc.local?

(sleep 300 && /usr/bin/cronwhip) &

Last edited by raymboard (2010-01-22 21:02:10)


Linux is not an operating system it's a kernel. You're using GNU/Linux. http://www.gnu.org/gnu/linux-and-gnu.html

Offline

#28 2010-01-22 21:04:51

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: Cronwhip - no more missed cronjobs

raymboard wrote:

And what if I ran cronwhip 8 times?

Then anything which would have been run once would get run 8 times.

Cronwhip uses the time of the last shutdown to determine which cronjobs would have been run since then. It's only meant to be run once at startup to run missed system/root cronjobs and once at login to run missed user cronjobs.

Just test it yourself with the "--dry-run" or "-n" option. It will print a list of commands that it would execute if run normally.

*edit*

raymboard wrote:

And am I really supposed to put brackets in /etc/rc.local?

(sleep 300 && /usr/bin/cronwhip) &

Yes. They enable the backgrounding of "sleep 300 && /usr/bin/cronwhip". Without them, it would block for 5 minutes and then run cronwhip in the background, which is not what you want.

Last edited by Xyne (2010-01-22 21:07:58)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#29 2010-01-22 21:25:10

raymboard
Member
Registered: 2010-01-22
Posts: 61

Re: Cronwhip - no more missed cronjobs

Do those brackets work in any shell or just bash?

I don't want it to wait for five minutes so I just use:

/usr/bin/cronwhip &

Linux is not an operating system it's a kernel. You're using GNU/Linux. http://www.gnu.org/gnu/linux-and-gnu.html

Offline

#30 2010-01-22 21:35:24

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: Cronwhip - no more missed cronjobs

I would expect them to work with other shells but you'll have to check the documentation of whatever shell you're using, or just test it directly with:

(sleep 5 && echo "done") &

If you don't want to wait 5 minutes then the line you posted should work.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#31 2010-01-22 21:36:11

jac
Member
From: /home/jac
Registered: 2009-05-19
Posts: 431
Website

Re: Cronwhip - no more missed cronjobs

They probably work in most any decent shell; they work in zsh for sure as well.

Great work Xyne! Just got it off of your repo, after needing to resync my db, you just updated it within the last few hours?

Offline

#32 2010-01-22 21:51:00

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: Cronwhip - no more missed cronjobs

@jac
Yeah, I fixed an error in the man page.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#33 2010-01-26 15:17:26

gav616
Member
Registered: 2008-01-16
Posts: 182

Re: Cronwhip - no more missed cronjobs

I've just updated 'dcron' from core (4.4-1), It seems that its had quite a few changes, and on this site it says its 'Anacron' like, now.
I think I'm also seeing it doing cronwhips job (It now has 'cronstamps' to determine at what time scripts have been run or missed)

can anyone confirm this?

Offline

#34 2010-01-26 15:38:31

gav616
Member
Registered: 2008-01-16
Posts: 182

Re: Cronwhip - no more missed cronjobs

yeap, ok.
as long as you add an 'ID' to the command, it logs a timestamp file.

Last edited by gav616 (2010-01-26 15:44:45)

Offline

#35 2010-01-27 19:21:44

raymboard
Member
Registered: 2010-01-22
Posts: 61

Re: Cronwhip - no more missed cronjobs

Yes the new dcron does have a feature for automatically running missed cron jobs.

Last edited by raymboard (2010-01-27 19:21:58)


Linux is not an operating system it's a kernel. You're using GNU/Linux. http://www.gnu.org/gnu/linux-and-gnu.html

Offline

#36 2010-02-07 11:45:51

skeleton
Member
Registered: 2010-01-15
Posts: 16

Re: Cronwhip - no more missed cronjobs

drostin77 wrote:

I made a VERY hacky way to get this working with suspend/resume at lunch[...]

I just wanted to say Thank you. Works perfect for me.

Maybe this could be included in the original package...

Offline

#37 2010-02-23 01:27:02

drostin77
Member
Registered: 2009-07-15
Posts: 45

Re: Cronwhip - no more missed cronjobs

I just wanted to say Thank you. Works perfect for me.

Glad to hear its working for someone!

If you are running it on a laptop btw I highly recommend wrapping any often-run cron jobs that make use of the internet or heavy use of your hard drive in a script that only runs the job if your computer is charging/online.  Without that this was eating my battery too much.  I made a script to do so but IIRC its written in ruby, so u'd need ruby installed (but it would be easy to xlate into bash.  It has a lot of file I/O / regex checks (i.e. it may be unreliable / system specific!), but let me know if you want the code, may at least be worth using as a reference:P

Offline

#38 2010-02-23 15:42:53

skeleton
Member
Registered: 2010-01-15
Posts: 16

Re: Cronwhip - no more missed cronjobs

No, I don't need them as I'm not running a laptop. But thanks anyway.

Offline

#39 2010-03-20 04:36:59

matthewbauer
Member
From: /usa/ks
Registered: 2009-07-20
Posts: 86

Re: Cronwhip - no more missed cronjobs

Would you make a daemon for cronwhip? This way it can be run on startup.


Libertarian Arch Linux User

Offline

#40 2010-03-20 05:53:20

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: Cronwhip - no more missed cronjobs

It should only be run once so a daemon would be overkill. If it did something at regular intervals then I would agree. The only advantage that I can see to creating a daemon would be to allow it to track uptime completely on its own (by creating a timestamp when the system goes down), but it introduces a new level of complexity that just isn't worth it imo.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#41 2010-10-30 09:54:44

RkG
Member
Registered: 2010-05-13
Posts: 12
Website

Re: Cronwhip - no more missed cronjobs

This script is great, it should be referenced in the cron's page of the wiki. Thank you


"Making the simple complicated is commonplace; making the complicated simple, awesomely simple, that's creativity." — Jazz composer and bassist, Charles Mingus

Offline

#42 2010-10-30 16:48:38

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: Cronwhip - no more missed cronjobs

Thanks, RkG.

You can insert a reference on that page yourself if you think it's appropriate. wink


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#43 2010-12-02 13:11:15

kekules_dream
Member
Registered: 2009-05-19
Posts: 102

Re: Cronwhip - no more missed cronjobs

Sometimes I get:

root# Use of uninitialized value $hours in addition (+) at /usr/bin/cronwhip line 60.  Use of
uninitialized value $mins in addition (+) at /usr/bin/cronwhip line 60.

after start up.

$ cat /etc/rc.local
#!/bin/bash
#
# /etc/rc.local: Local multi-user startup script.
#

(sleep 300 && /usr/bin/cronwhip) &

Any suggestions?

Offline

#44 2010-12-02 13:28:25

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: Cronwhip - no more missed cronjobs

The "$hour" and "$mins" variables of that line are parsed from the output of the following command:

last -x | grep shutdown | head -1

The next time that you notice the error message, run that command in a terminal and post the output here. Also run the following command afterwards and post the output if it's different from the previous command:

LC_ALL=C last -x | grep shutdown | head -1

My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#45 2010-12-05 08:05:58

RkG
Member
Registered: 2010-05-13
Posts: 12
Website

Re: Cronwhip - no more missed cronjobs

Ok Xyne I've added a small reference at the end of cron's page for available async job processing tools, my english is a bit buggie sometimes, I'm accepting corrections/improvements :-)


"Making the simple complicated is commonplace; making the complicated simple, awesomely simple, that's creativity." — Jazz composer and bassist, Charles Mingus

Offline

#46 2011-04-30 22:42:54

noddy21007
Member
Registered: 2011-04-30
Posts: 3

Re: Cronwhip - no more missed cronjobs

Xyne wrote:

The "$hour" and "$mins" variables of that line are parsed from the output of the following command:

last -x | grep shutdown | head -1

The next time that you notice the error message, run that command in a terminal and post the output here. Also run the following command afterwards and post the output if it's different from the previous command:

LC_ALL=C last -x | grep shutdown | head -1
 Use of uninitialized value $hours in addition (+) at /usr/bin/cronwhip line 60.
 Use of uninitialized value $mins in addition (+) at /usr/bin/cronwhip line 60.

The reported problem (above) is due to /var/log/wtmp log having been rolled to /var/log/wtmp.1 resulting in last shutdown not being found.

Would it be possible to search wtmp.1 (last -xf /var/log/wtmp.1) if not found in wtmp ?

Offline

#47 2011-05-01 00:11:40

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: Cronwhip - no more missed cronjobs

noddy21007 wrote:

 Use of uninitialized value $hours in addition (+) at /usr/bin/cronwhip line 60.
 Use of uninitialized value $mins in addition (+) at /usr/bin/cronwhip line 60.

The reported problem (above) is due to /var/log/wtmp log having been rolled to /var/log/wtmp.1 resulting in last shutdown not being found.

Would it be possible to search wtmp.1 (last -xf /var/log/wtmp.1) if not found in wtmp ?

Thanks for reminding me about this and posting a solution.

It now uses globbing (/var/log/wtmp.*) to check for rotated wtmp log files if the current one does not return the last shutdown. If that fails then it simply sets the last shutdown to over a year ago.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#48 2012-02-26 17:35:17

kekules_dream
Member
Registered: 2009-05-19
Posts: 102

Re: Cronwhip - no more missed cronjobs

Is cronwhip compatible with cronie?  I have cronie installed and I just updated cronwhip to 2012.02.16.56696-14.  I modifed rc.local as recommended.  If I reboot, log in as root, and wait 5 minutes, I get:

no crontab for root

cronie installs an /etc/anacrontab.  Is there a set of instructions somewhere about setting up cronwhip? 
Thanks.

Offline

#49 2012-02-26 17:56:33

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: Cronwhip - no more missed cronjobs

Cronwhip just needs a crontab in the following format:

01 * * * *  /usr/sbin/run-cron /etc/cron.hourly
02 00 * * * /usr/sbin/run-cron /etc/cron.daily
22 00 * * 0 /usr/sbin/run-cron /etc/cron.weekly
42 00 1 * * /usr/sbin/run-cron /etc/cron.monthly

If you can tell me how to extract that from cronie/anacrontab then I should be able to add an option to cronwhip.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#50 2012-02-26 20:34:12

kekules_dream
Member
Registered: 2009-05-19
Posts: 102

Re: Cronwhip - no more missed cronjobs

Thanks for the info.  I think cronie is the default now.  I don't know for sure how to extract that but I can show you what anacrontab contains:

# /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=root
# 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

Offline

Board footer

Powered by FluxBB