You are not logged in.
Pages: 1
I updated my syslog-ng and it recommended logrotate, so on a whim I googled it... very useful! I would like to cron it like it was in this tutorial: http://www.linux.com/feature/48390 but the trouble is, my laptop would have to be on at midnight. It isn't always, so I googled a little more, and discovered anacron. Ok, it will play missed cron's at boot-up. Perfect!
Trouble is, I have no idea how to set up anacron to automate logrotate. Anyone care to enlighten me? I simply want to keep my system logs tidy and save space. I rarely ever have to look at them, so keeping them for more than a month is rather silly.
Thanks!
Last edited by LeoSolaris (2009-01-25 02:21:51)
I keep getting distracted from my webserver project...
huh? oooh... shiny!
Offline
just put (..., @crond, @anacrond, ...) in the DAEMONS array in your rc.conf. no configuration needed for anacron. it just checks at startup the time when cron was last executed.
so keeping them for more than a month is rather silly.
i keep them for 1 year (52 weeks). you can also compress the logs. logs are only textfiles. my /var/log is under 30mb.
Offline
Ah, alright, so then anacron would use the same setup style as cron, just add 'ana' at the right place?
I keep getting distracted from my webserver project...
huh? oooh... shiny!
Offline
Running it at boot is like what DonVla said. Be sure to also run it upon resuming from sleep.
/etc/anacrontab is the configuration file, you can check what it contains.
Offline
Maybe it's changed, but the last time I checked anacron is completely independent of cron. You need to specifically assign anacron it's own tasks and it can only guarantee that they will be run at some point during the day.
This is exactly why I create cronwhip: http://bbs.archlinux.org/viewtopic.php?pid=444058
All you need to do is run cronwhip once at startup and it will handle any cronjobs that should have been run while the computer was off.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
I think I like cronwhip's idea. I will have to test it out as well. I haven't given up on anacron, and thanks for the location of it's config file, I was looking for it.
Thanks guys. I am going to leave it open till I pick a method, then mark it solved. I did google anacrontab and I think I have a pretty good idea what to do with it to get logrotate... well rotating.
I keep getting distracted from my webserver project...
huh? oooh... shiny!
Offline
Good luck getting everything set up the way you want, LeoSolaris.
Just to be clear, cronwhip requires no configuration. It will automatically detect what should have been run by checking the invoking user's crontab.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Good luck getting everything set up the way you want, LeoSolaris.
Just to be clear, cronwhip requires no configuration. It will automatically detect what should have been run by checking the invoking user's crontab.
Thanks, I would have spent a couple of hours looking for the conf! It is a fine and useful program, thank ya for writing it.
I keep getting distracted from my webserver project...
huh? oooh... shiny!
Offline
Ok... I have started to figure out how to get logrotate to work with cron. At least, I have got logrotate to work, and I figured out that I have to use
sudo crontab -e
to get the right place to put cron... I think.
0 0 * * * /usr/sbin/logrotate /etc/logrotate.conf
went right in the sudo crontab...
I tested the command
sudo /usr/sbin/logrotate /etc/logrotate.conf
and it went off without a hitch.
Now the issue is when I use cronwhip with the -n switch (or --dry-run, tried both) it is giving me:
[zeddicus@Archer ~]$ cronwhip --dryrun -v
Use of uninitialized value $hours in addition (+) at /usr/bin/cronwhip line 44.
Use of uninitialized value $mins in addition (+) at /usr/bin/cronwhip line 44.
I am not sure what I am doing wrong...
Maybe it is because I just made the cron job? or do I need to run cronwhip as root to activate root's crons?
I keep getting distracted from my webserver project...
huh? oooh... shiny!
Offline
Edited for clarity:
on my system, i believe by default, logrotate is a daily cron job stored in /etc/cron.daily/ as a script called logrotate
$cat /etc/cron.daily/logrotate
#!/bin/sh
/usr/sbin/logrotate /etc/logrotate.conf
these cron.daily's should really be run by whatever replacement cronjob manager your bring in as this updates your whatis database among other things
i recommend fcron as a drop in replacement for cron
But fcron does not assume that your system is running neither all the time nor regularly : you can, for instance, tell fcron to execute tasks every x hours y minutes of system up time or to do a job only once in a specified interval of time.
pacman will ask you to remove [d]cron when you `pacman -S` in fcron; no worries, anything that was run by cron will be run by fcron. be sure to replace crond with fcrond in your rc.conf daemons array
fcron also lets you setup specific sets of cron jobs to be run as certain users (this is why i originally googled for it)
sudo fcrontab -u USER -e
will edit any USER's crontab
sudo fcrontab -u systab -e
shows the cron.daily/weekly/etc setups; here's mine:
!mail(no)
&bootrun 01 * * * * /usr/sbin/run-cron /etc/cron.hourly
&bootrun 02 00 * * * /usr/sbin/run-cron /etc/cron.daily
&bootrun 22 00 * * 0 /usr/sbin/run-cron /etc/cron.weely
&bootrun 42 00 1 * * /usr/sbin/run-cron /etc/cron.monthly
the bootrun modifier means if the machine was down during the scheduled runtime, run the job at boot
i think this is what you're looking for
Last edited by brisbin33 (2009-01-14 22:08:02)
//github/
Offline
yay Open source! The land of nearly too many options! (nearly)
Thanks guys (or gals)!
I had to reformat, but I am back up and running now, so I get to choose this stuff all over again. (I forgot to save all of this configuring)
Last edited by LeoSolaris (2009-01-15 17:57:38)
I keep getting distracted from my webserver project...
huh? oooh... shiny!
Offline
Thanks guys!
I ended up using cronwhip after a little messing with each. All three were handy and I will keep the others in mind if I need some of the functions in them.
I keep getting distracted from my webserver project...
huh? oooh... shiny!
Offline
Thanks guys!
I ended up using cronwhip after a little messing with each.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
I liked the simplicity, and I wanted to support a fellow Archer
I keep getting distracted from my webserver project...
huh? oooh... shiny!
Offline
Pages: 1