Web Hosting Talk







View Full Version : Cron Question


jethbrown
12-27-2004, 05:25 AM
I have a client that needs their sql backed up everyday. His website was tampered with by one of his members we think. I put in a cron job to do the sql dump from his cpanel for him and tried to designate a folder outside of his account, but I got a authorization error.

Can a job be put on the SSH, for clients mySQL? Not sure if this is making any sense. The client is NetNavy, but i want to save it under the client gameserv.

This is the code I have:
* 0 * * * mysqldump --user=netnavy_erick --password=EDITED --quick --add-drop-table --add-locks --extended-insert --lock-tables --all netnavy_vbulletin | gzip > /home2/netnavy/public_html/sqls/netnavy-`date -I`.gz > /dev/null

This is the code I want:
* 0 * * * mysqldump --user=netnavy_erick --password=EDITED --quick --add-drop-table --add-locks --extended-insert --lock-tables --all netnavy_vbulletin | gzip > /home2/gameserv/public_html/sqls/netnavy-`date -I`.gz > /dev/null

What do I have to edit on the server? crontab -e ? Or is there a better way.

Oh this is a Fedora Server, with CPanel and I own the server, so I have access to SSH.

choon
12-27-2004, 05:53 AM
Can't you just create a script and put those code in that script such as /home/USERNAME/mycronscript.sh:
#!/bin/sh
MAILTO=''
mysqldump --user=netnavy_erick --password=EDITED --quick \
--add-drop-table --add-locks --extended-insert --lock-tables --all \
netnavy_vbulletin \
| gzip > /home2/gameserv/public_html/sqls/netnavy-`date -I`.gz > /dev/null
Then check for any exisiting crontab under that username:
crontab -u USERNAME -l
Replace USERNAME to the real username.
If nothing then create a /home/USERNAME/crontab.txt with the following:
* 0 * * * /bin/sh /home/USERNAME/mycronscript.sh >/dev/null 2>&1
Then add it to that username crontab using root:
crontab -u USERNAME /home/USERNAME/crontab.txt
Look for my reply about crontab in the following thread might helps:
http://www.webhostingtalk.com/showthread.php?s=&threadid=224985