Gnuru.org
Productive Linux


Subscribe

 Subscribe via Feedburner in a reader

Enter your email address:

Delivered by FeedBurner


Login
Login:
Password:



Don't have an account?
Sign up to Gnuru.org
Forgot your password?

Five Things You Can do With Cron
11 August 2008 @ 21:20 BST
by Paul

I used to never give a thought to cron. Now, I think, it's the best thing since sliced bread.

It's one of those simple little software tools that just sits on your hard drive and goes about its work silently in the background with barely a complaint.

Usually, a slew of cron jobs are installed when you install your Linux system. These jobs, rotate log files, clear caches and mail queues.

But cron isn't just for the installers to worry about, it's also a useful tool for you to use in your day-to-day.

Here are five things that can be done with cron:

Backup files using rsync everynight
My crontab includes this line,
0 22    * * * rsync -a --delete ~/Maildir/ ~/backup/Maildir/
This backs up my Maildir directory to a backup folder at 10 p.m. everyday. The directory
~/backup
is symlink to another disk.
Backup a database
I also use cron to do a database dump of both mysql and postgresql databases using the
mysqldump
and
pg_dump
commands.
Run tests over night
If you're writng software you may have an extensive test suite that may take a long time to run. You can use a cron job to run the suite periodically at night and so not tie up valuable resouces during the day.
Delete print queues at the end of the day
Sometimes you have hanging print jobs on the print key, you can use cron to delete those at the end of the working day to make sure they don't suddenly coma alive when you least expect it and your printer is suddenly spitting out paper and you can't remember why.
Fetchmail every few minutes
You can use cron to run fetchmail every few minutes to retrieve mail from a POP3 or IMAP server. Personally, I don't use this any more, but run fetchmail with the '-d' switch that backgrounds it.

Cron is a fantastically flexible tool, think creatively to see how it could help you.




Comments disabled