home | list info | list archive | date index | thread index

Re: [OCLUG-Tech] Simple Chron Job request

On 03/06/16 02:38 PM, Trevor James wrote:
> Good Day everyone, I know this is one that someone in the know can do in about 2 minutes and will take me a couple of hours of google time to figure out.
Dunno if it's the best way to test the backup or so but the task it self
is simple enough (and with some testing it took 5min, not 2)

#Prep - create the table
mysql test -e "create table test ( counter int auto_increment, changed
timestamp default current_timestamp , primary key (counter));"

#bash script ~/bin/AddData.sh
sleep $(($RANDOM%60*60)) # sleep 0-59 minutes
mysql test -e "insert into test values (null,null);" # add the value

0 * * * * ~/bin/AddData.sh

> I would like to set up a chron job to add a record to a database in MySQL.
> Background, I wish to do a reasonable test of our backup system on MySQL databases.
> I have a TurnKey LAMP server setup, so now I wish to add a record to a table in a database (I haven't set anything up just yet it will depend on the data I can push into the table)
> I can go into MySQL create Database, Create Table etc, so that is ok, so let's assume I have TestDatabase with TestTable with one field called TestData (type can be anything, but how about a date/time or string)
> Now I would like to set up a chron that every X minutes (I would like something semi random, but let's say every 83 minutes if it is easy) add a new record to the database
> date > mysqldatabse
> Then between backups I will kill the machine and restore from backup and then run a mysqlcheck on the database.
> In theory we should have dataloss (since the backup is not continuous) which is acceptable, a corrupted database will not be which is what I wish to verify
> Thanks in advance for any assistance you can give.
> T. James
> _______________________________________________
> Linux mailing list
> Linux [ at ] lists [ dot ] oclug [ dot ] on [ dot ] ca
> http://oclug.on.ca/mailman/listinfo/linux