LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Setting up automatic jobs (https://www.linuxquestions.org/questions/linux-newbie-8/setting-up-automatic-jobs-180691/)

Phaethar 05-12-2004 11:15 AM

Setting up automatic jobs
 
Hey all,

I'm wondering what the best method is under Linux (Fedora Core 1) to set up some set jobs to run every day. Here's what I want the job to do:

1. Stop the MySQL service.
2. Compress the /var/lib/mysql folder into a single RAR file.
3. Start the MySQL service as soon as the archive is created.
4. Move the archive to a network folder.

Each of these are easy on their own. I want to have a single job that does each of these in turn. I'm aware of Cron, but I'm not sure how to get it to run something like this. As far as I know, I would have to specify the time of day I want each job part to run. I don't know how long the creating of the archive will take, and it will vary depending on how big the databases are. I can't very well have the service trying to start and modify the tables while they are being compressed.

So, I'm hoping someone can suggest a method to run each of the steps above in order, as soon as the previous step completes so I don't have to specify a time for each.

Thanks.

Blinker_Fluid 05-12-2004 11:47 AM

I would create a script that does what you need then just put the script into cron.

Just guessing but your script would be something like this:

/etc/init.d/mysql stop
tar -zcf /tmp/database_backup.tgz /var/lib/mysql #not sure what rar command would be.
sleep 2 #just to be sure it completes
/etc/init.d/mysql start

Then you would need to setup cron:
crontab -e
put a line in like this:
* 1 * * * /root/backup_script.sh

kam_kenneth 05-12-2004 11:49 AM

This might not be a direct answer but you can start by going to linux tutorial .info
here is the link to the cron section..... http://www.linux-tutorial.info/cgi-b...l?78&0&305&0&3
Hope this helped a bit...


All times are GMT -5. The time now is 11:50 AM.