Click to See Complete Forum and Search --> : cron job
Helmudt
02-02-2001, 05:51 AM
Hi All,
a) Is this a valid cron job?
"02 * * * * tar -zcf /backup/jo.tar.gz /home/jo/data"
or do I have to write some script?
b) How do I load this to the crontab file?
Thanks
holloway
02-02-2001, 06:28 AM
(as the user jo) at the prompt type: crontab -e, and put the line in there.
not sure if its right tho.. iirc that would run the command on the 2nd minute of every hour (I *think*) maybe it would be:
0 2 * * * tar -zcf /backup/jo.tar.gz /home/jo/data
(which runs it at 2am everyday.. that was what you were aiming for, right :D)
Helmudt
02-02-2001, 08:00 AM
How do I know if crond is running? I have changed the command to run every 2 min.- for test only, but nothing happens. Is the command wrong?
2 * * * * tar -zvf /backup/jo.tar.gz /home/jo/data
Thanks :confused:
iDxMan
02-02-2001, 09:00 AM
Originally posted by Helmudt:
How do I know if crond is running? I have changed the command to run every 2 min.- for test only, but nothing happens. Is the command wrong?
2 * * * * tar -zvf /backup/jo.tar.gz /home/jo/data
Thanks :confused:
The above will run every hour on minute 2.
try:
*/2 * * * * tar -zvcf /backup/jo.tar.gz /home/jo/data
1) When do you want to run this?
2) type crontab -e to edit your personal crontab.
or if you are using Vixie cron you can edit /etc/crontab and add it in there.
edit: oh yah. type ps -ef|grep crond to see if its running.
-r
[ 02 February 2001: Message edited by: iDxMan ]
Infested Flar
02-02-2001, 09:22 AM
am sure this (http://www.linuxnewbie.org/nhf/intel/misc/scheduling.html) could help
:cool:
jesterspet
02-03-2001, 06:36 PM
The great thing about Llinux is that there is usually more than one way to do things (kinda like programming in PERL.) Cron is the same way.
The way I set up cron jobs is to have a fine (I call mine "CronJobs") in your home directory. In that file you put everything you would like cron do to for you. Everthing in that file will be run as you ( as opposed to say ROOT.)
As long as you keep all of your jobs on one line per job, this should work. below is an example of what a line should look like
0 * * * * cd /home/rushl/setiathome-3.0; ./setiathome -nice 19 -email > /dev/null 2> /dev/null
After you have your job in there issue the command "crontab CronJobs". That will update your crontab and make your changes live. If for some reason you want to stop a job, you simply comment out the line with a "#" symbol, save your work, and give the "crontab CronJobs" command again.
I use this as I had trouble with editing my crontab directly (vi and i had not yet been properly introduced, and I wnated to use something simpler like pico.)
Hope this helps.
[ 03 February 2001: Message edited by: jesterspet ]
Helmudt
02-05-2001, 06:17 AM
Thanks guys,
I got it running!
Just anouther problem:
I use cron to do daily backups. I want cron to create everyday a new file. The filename must contain the username and the date.
Thanks
trauma
02-05-2001, 07:34 AM
keyphrases:
1. daily backup
2. filename must contain username and date
1. i think you got it running using that cron job you just did. the only thing left to decide about is if the backup should always be full or incremental.
2. get a help on date on what format you want to display then:
tar zcvf "$(date \d\t)$USER" ......
couldn't check this right now though, i'm in an internet cafe in a win98. you need to do some tweaking with the date format. you can use variable expansion to substitute them into a filename.
hope this helps.
:) :)