how to do this with a cronjob?

Posted by HD Fanatic, 07-13-2007, 04:18 PM
I want to copy a sql file from my secondary hdd to my NAS daily at 5AM and overwrite the older file with the same filename without prompting for confirmation. the .sql file is in: /backup/cpbackup/daily/server/mysql/john_forum.sql and the NAS is located in /mount/stuff/ Could you tell me what to type? Thanks.

Posted by Patrick, 07-13-2007, 04:21 PM
Something like: 0 5 * * * cp /backup/cpbackup/daily/server/mysql/john_forum.sql /mount/stuff/john_forum.sql > /dev/null

Posted by HD Fanatic, 07-13-2007, 09:32 PM
That won't overwrite the older file though, right?

Posted by Patrick, 07-13-2007, 09:34 PM
That will overwrite the old file, without asking for confirmation. ... unless you have some really weird setup in place that always asks when using cp?

Posted by MaximSupport, 07-13-2007, 10:21 PM
Dear HD Fanatic, Use rsync to achieve this. Best Regards.

Posted by HD Fanatic, 07-15-2007, 07:25 PM
cp always asks for confirmation before it overwrites. Thanks Tom, I had to remove the -R to make it work. building file list ... done ERROR: destination must be a directory when copying more than 1 file rsync error: errors selecting input/output files, dirs (code 3) at main.c(494) [receiver=2.6.9] rsync: connection unexpectedly closed (8 bytes received so far) [sender] rsync error: error in rsync protocol data stream (code 12) at io.c(453) [sender=2.6.9] Last edited by HD Fanatic; 07-15-2007 at 07:36 PM.

Posted by Patrick, 07-15-2007, 07:33 PM
Must be a Linux thing. Edit: 0 5 * * * cp -f /backup/cpbackup/daily/server/mysql/john_forum.sql /mount/stuff/john_forum.sql > /dev/null The -f flag should overwrite the file without asking for confirmation...

Posted by Lightwave, 07-15-2007, 07:36 PM
That's most likely only a local shell setting. You most likely have cp or rm aliased to cp -i, or rm -i It's standard in many distributions setup. Check your .cshrc and/or .bashrc file. In otherwords... executed through cron... cp wouldn't ask for confirmation.

Posted by MaximSupport, 07-15-2007, 11:08 PM
Dear Lightwave, Indeed, you can also issue following command if you are trying to do this on same machine. alias cp=cp cp ..... Best Regards.

¿Fue útil la respuesta?

 Imprimir éste Artículo

Leer también

PHP Issue

Posted by pluddies, 03-01-2010, 05:58 PMI have recently switched from a HostGator.com reseller...

Websites hacked, can't find the file

Posted by crk91, 04-20-2009, 09:30 PMI don't know how this happened but someone got into my VPS...

Custom stamp/engraving tool for PHP

Posted by alias3729, 02-09-2011, 07:32 PMWondering if there's something similar to the websites...

Q: Prevent DDoS attacks with restarting httpd ?

Posted by NameTyper, 01-12-2008, 11:36 AMHi all Just a short question. Can you restart the...

My tar files is invisible!

Posted by hbhb, 03-28-2008, 12:07 PMHi, I need help, I just execute a command to tar a...