Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cron

Status
Not open for further replies.

phet

IS-IT--Management
Mar 7, 2001
14
US
I am new to linux. How do I set the cron tab to backup my linux box everyday at 9pm. Any suggestion.
 
do you know the command you need to use to backup the machine? Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
A general cron entry goes like this:

05 10 Mar Mon command here

hour=5 am day of month month day of week command

To run every day:

017 * * * command

Good luck. I don't know the backup command...you might consider "tar"ing all the files on your system to a backup drive...
 
Phet,

If you know the backup command you need to run automatically I'll just explain the cron format for you -- if you don't we should start off by talking about backup commands :) Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
This the command line I use to back up my tape drive:
tar czvf 20 /dev/st0 /home*
 
I'm not a linux person really, so there might be some differences between what I post here and what will work correctly on your system.

First of all, have a look at the man page for crontab on your system: type 'man crontab | less'

Take special note of the format, the idea of cron is to be able to run a command on a specific minute of a particular hour on the specified day -- or days for that matter.

From the Solaris man page:

A crontab file consists of lines of six fields each. The
fields are separated by spaces or tabs. The first five are
integer patterns that specify the following:

minute (0-59),
hour (0-23),
day of the month (1-31),
month of the year (1-12),
day of the week (0-6 with 0=Sunday).

Each of these patterns may be either an asterisk (meaning
all legal values) or a list of elements separated by commas.
An element is either a number or two numbers separated by a
minus sign (meaning an inclusive range). Note that the
specification of days may be made by two fields (day of the
month and day of the week). Both are adhered to if specified
as a list of elements


so, login as root, run the command 'crontab -e', enter the following line and save the file.

0 21 * * tar czvf 20 /dev/st0 '/home*'

Should run your tar command at no minutes past 21:00 every day. Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Mike,
The only thing that I would change is to put the full path in the cron entry:
0 21 ** /bin/tar -czvf 20 /dev/st0 '/home*"

Says the Manager to the person that invented the modem: "Tell me again why you need two prototypes?!?"
 
Yep -- I agree. Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top