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.

Was this answer helpful?

 Print this Article

Also Read

.htaccess question

Posted by MikeWalczak, 10-23-2012, 02:25 PMHey everyone, I've got a question about .htaccess. I...

Chinese interface reseller control panel

Posted by aming, 09-02-2002, 04:40 PManyone can help me? I am looking for a good reseller...

Disallow a site from sending out emails

Posted by HappyPike, 05-04-2007, 12:51 AMHi, Is there a way to disallow a certain site from...

Configuring pureFTPd on a VPS

Posted by eta aquarii, 03-27-2008, 02:32 PMHi, I'm trying to install and configure pureFTPD on...

Question about Server Load?

Posted by olddocks, 01-10-2008, 07:09 PMi run about 3 sites all on a shared server with bluehost....