You are not logged in.
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.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
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
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*
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 Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
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
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 Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
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
@jac
Yeah, I fixed an error in the man page.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
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
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
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
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
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
No, I don't need them as I'm not running a laptop. But thanks anyway.
Offline
Would you make a daemon for cronwhip? This way it can be run on startup.
Libertarian Arch Linux User
Offline
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 Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
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
Thanks, RkG.
You can insert a reference on that page yourself if you think it's appropriate.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
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
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 Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
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
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
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 Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
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
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 Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
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