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

Revecom Down

Posted by David@Digisurge, 09-11-2001, 01:25 AMAnyone else getting 404 errors for their Revecom...

FTP login problem

Posted by crazyaboutlinux, 04-14-2009, 10:42 AMone of my client is facing to connect FTP server...

How to show hidden (dot) files by default and...?

Posted by gurika, 09-13-2007, 10:10 AMHello, on my old centos servers I can show hidden (.file)...

how to partion drive

Posted by kmwrestle, 03-27-2008, 11:54 PMim assembling my server now....waiting on the 90degree...

PHP Issue

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