Talk:Cron

From TextUsers

Jump to: navigation, search

play 3gp video westgate river ranch reviews tim mcgraws song drugs or jesus lpn cheap prom shoes license bureau columbus boys teen puberty kari wurher movies nutcracker raleigh map spitz breed information new tamil movies downloads asian championship netball ut vols pictures weight watcher online coupons map webmap top pictures of porn breakfast in america feng shui house one headlight train bedding sets movies under the stars canberra arizona dust storm video microsoft office multi user license austin360 movies low cost pharmacy http page nortenos lisa movie raye sitemap 54th massachusetts sitemap podutil crack movie sexual porn line of duty video fiji vacations extract dvd video mac attorney licensing board itunes music videos mp3dancer crack liqour licensing qld movie my merry christmas landscape plants impregnation video la revanche movie aol movie download ashlee by l.o.v.e music simpson video cheap hotel in london adina jewel download free ringtone nokia free matlab download triamcinolone acetonide cream

recipes

Good overview of cron. We should brainstorm some common uses and write corresponding sample cron entries.

  • backups
  • starting applications upon system reboot
  •  ???

Also, we should cover the basic rules like not running cron scripts more than once an hour. --Madams 08:32, 25 November 2006 (UTC)


I agree. I took liberty to start writing for the reason that I am learning too. Please check my English and the correctness of the article. Thanks, Ngungo 16:10, 25 November 2006 (UTC)

I am working on this article. Ngungo 01:35, 27 November 2006 (UTC)

http://help.textdrive.com/index.php?pg=kb.page&id=113

9.8. Backing up a MySQL database

Although TextDrive does make daily backups of each server, primarily as a disaster recovery precaution, it's a good idea to setup a backup process for your important databases. We may be able to restore the odd deleted file or database from our backups, but this may not be suitable for your needs. Also due to the nature of our backup scheme and MySQL InnoDB data, our backups cannot be used to restore InnoDB data.

Fortunately, there'™s an easy way to setup a daily backup of your MySQL databases (InnoDb or otherwise). The following directions will establish a daily cron job that will backup a specific mysql database to a backups directory. Each backup will be compressed (in gzip format) and named according to your database name and the date. This cron job will also remove any backups that are older than a week (7 days) to prevent your backups directory from filling up.

1. At the root level of your account, create a backups directory to store your MySQL backups:
     /users/home/username/backups
2. Also at the root level of your account, create a scripts directory to store your backup script
3. Download the daily_backup.sh file linked at the bottom of this article. This file is a bash script and contains commands 
   to run your backup process.
4. Open the file in a text editor and replace USERNAME, PASSWORD, and DATABASENAME with the appropriate values.
Note: If you'd like to make the script more secure to protect your password, set the files permissions to 700. 
You can do this from the command line with chmod 700 scripts/daily_backup.sh
5. Upload the edited daily_backup.sh file to the scripts folder you created previously
6. Log into Webmin (https://webmin.server.textdrive.com/)
7. Under the System section, click Scheduled Cron Jobs
8. Click Create a new scheduled cron job.
9. In the Command field, enter the following:
    /bin/sh /users/home/USERNAME/scripts/daily_backup.sh
   Don't forget to replace USERNAME with the appropriate value.
10. In the Description field, enter Daily MySQL Backup
11. Under When to execute, select Times and dates selected below ..
12. Under Minutes and Hours, select Selected .. for each and select some random values so that 
    the cron job doesn’t run at a common time (like 12:00 am)
13. Under Days, Months, and Weekdays, select All for each.
     This will set your cron job to run each day at your chosen time
14. Click Create button. You should now see your newly created backup cron listed in Scheduled Cron Jobs.

You’ve now created a Daily cron backup of your mysql database. If you’d like to preserve backups for longer than a week, like say 2 weeks, then set the -mtime value to +14.

You can also backup all your MySQL databases at once by substituting the DATABASENAME with --all-databases, but you’ll need to use your main account user name and password for this to work.

To restore the backup, follow the directions on Importing/Exporting MySQL data. Use the phpMyAdmin option as it will automatically decompress the file for you on import. When you do restore, make sure to use a clean database to avoid any possible errors.


#!/bin/sh

# This file will run a backup of your desired MySQL database and
# remove any backups older than 7 days.
#
# If youÕd like to preserve backups for longer than a week, like say 
# 2 weeks, then set the '-mtime' value from '+7' to '+14'.
#
# NOTE: Make sure to create a 'backups' folder in the root of your 
# account and replace USERNAME, PASSWORD, and DATABASENAME with 
# the appropriate values.

/usr/local/bin/mysqldump --opt --skip-add-locks --user=USERNAME --password=PASSWORD DATABASENAME | gzip > /users/home/USERNAME/backups/DATABASENAME_`date "+%Y-%m-%d"`.gz
cd /users/home/USERNAME/backups/
/usr/bin/find *.gz -mtime +7 -delete