PDA

View Full Version : Cron Jobs



webmastadj
23rd June 2008, 04:39 AM
I need some help with cron tasks. I understand how to set-up a cron and such. What I want to know is there a way to make a cron run on sun, wed, sat?

Also, the cron task is backing up my server to an external hard drive and I would like to know how in a bash command can I make it so it won't override the other files. For example, I want to make an archive.

Say I want mon, tuesday, wednesday, .... in separate files but not having to make a new schedule for each day. That way if I need to revert back to a setting that is 10 days old, I can. Right now, my backups overwrite each other not giving me a history.

daverj
23rd June 2008, 05:54 AM
man 5 crontab

Dangermouse
23rd June 2008, 06:06 AM
Hi
I use gnome-schedule an easy gui

su
yum install gnome-schedule
Thats if you can connect to fedora repos at the moment they dont seem to be working again here in the uk unless its just me :rolleyes:

marcrblevins
23rd June 2008, 09:21 AM
Check my backup script I use in my /etc/cron.daily
Does full backups on Sunday and first of each month. The rest are incremental backup. Named zbackup.cron, named it that way cause I want it done last.

http://kiriyamablevins.dyndns.org/scripts

webmastadj
25th June 2008, 05:49 PM
marcrblevins:
That is a nice script. That answers a lot of my questions on how to work with Shell scripts. My next question was going to be how to make it so the backup makes the file name the same as date, and that answered my question. Thanks

dangermouse:
Thanks, but I don't use GUIs on the system. Most of my administration I do via SSH because I have two servers and it would be a pain to switch back and forth. Also, I try and allocated all the resources to apache, mysql, and ftp so there is basically nothing installed on the server except service to help support those services. I do have a GUI installed just in case, but I use the KDE and have it in run-level 3 by default so it doesn't start up.

daverj:
I have seen the man command before but it never seems to work for me. Of course I can read it now and it works for me. Tell me if I am right. if I type ....,"*/2",.... in the day section, then the script will run every 2 days correct? Basically it is an array inside of an array; at least that is how I see it?

marcrblevins
25th June 2008, 06:22 PM
Don't worry about that filename, it will be the hostname + the date value. Got the script from:
http://tldp.org/LDP/solrhe/Securing-Optimizing-Linux-RH-Edition-v1.3/chap29sec306.html

I tweaked it for my taste.

webmastadj
26th June 2008, 01:49 AM
Do you know where I can learn all those sh commands?

Another thing I am trying to do is get the disk usage (du) but only the total amount a folder is taking up. For instance, put the return value of "du -s user" into a varible. Right now it returns "66900 user." What I want it is to return the just the number to a variable so I can compare it.

I believe it is possible because there it was done with the date command. Does anyone know where I can look up this type of information? Thanks.

webmastadj
26th June 2008, 02:37 AM
nevermind. I found that I can get the du with just the file size by using "du -s user | cut -f1"