Need help schedule back script
Hi everyone,
Greetings. I am new to Linux, I am doing the following to backup the logs and data. Here Logs are generated every 30 mins (usually size in GB for 30 mins) log pattern are log_backup_somenumberwhere it will have connection to next file. I dont get that Data are generated every day data pattern are yyyy-mm-dd_databackup_0_1 yyyy-mm-dd_databackup_1_1 yyyy-mm-dd_databackup_2_1 yyyy-mm-dd_databackup_3_1 yyyy-mm-dd_databackup_4_1 yyyy-mm-dd_databackup_5_1 Both logs and data are in different folder In the linux crontab i am trying like below 30 05 * * * zip -r path/$(date +\%Y\%m\%d)_databackup_.zip path/$(date +\%Y\%m\%d)_databackup_*_1 * */1 * * * zip -r path/log_backup_$(date +\%Y\%m\%d)_.zip path/log_backup_* ( I want to zip all the data and log files to commonfolder.zip every hour and data one day) 00 06 * * * find /path -mtime -1 -exec rm -f {} \; 10 */1 * * * find /path -mtime -1 -exec rm -f {} \; (10 minutes after 1 hour i want to remove the original files) 10 06 * * * mv /path/$(date +\%Y\%m\%d)_databackup_.zip /tmp/data 20 */1 * * * mv /path/log_backup_$(date +\%Y\%m\%d)_.zip /tmp/log (20 minutes after 1 hour i want to move to some temp directory) Now i want to copy files from temp directory windows server using pscp.exe on the windows scheduler for every hour back in linux 20 06 * * * rm -r /tmp/* 30 */1 * * * rm -r /tmp/* But the whole process what i am trying to do is looking very clumsy and fear not correct. Can some one pls guide for a script solution for the above . Thanks a lot for the patience Regards pearl |
A point about '*/1'; this is redundant as it means effectively the same as '*' ie take every legal value; in your case every hour.
'*' in the minute field (ie 1st field) means do it every minute; probably not what you want. Don't delete /tmp/* as the /tmp dir is used by the system to store many temp files (other than your app) - take a look some time Personally I wouldn't put complex cmds like that in cron anyway; the common convention is to write bash scripts that do what you want and call them. |
Hi Chris,
Thank you for your reply. How would I go for writing in the bash script because I am not familiar with it. Please guide. Regards Pearl |
Writing shell scripts is a key skill, try the following...
The first is a tutorial in increasing skill, the others are more like references (by example) but easy to read and well worth doing so. Enjoy :) http://rute.2038bug.com/index.html.gz http://tldp.org/LDP/Bash-Beginners-G...tml/index.html http://www.tldp.org/LDP/abs/html/ |
Quote:
Quote:
|
All times are GMT -5. The time now is 05:15 PM. |