CRON Job - saving to a different server?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers CRON Job - saving to a different server?
# 1  
Old 05-29-2004
CRON Job - saving to a different server?

Thanks for the all the help last evening on CRON jobs. It's now working.

Is it possible with cron to save a backup of a file to a different server or location? The idea being that if one host goes arse over tit, I'll have a backup of the DB on another server?

Many thanks,
Ed Ludlow
# 2  
Old 05-29-2004
Re: CRON Job - saving to a different server?

Quote:
Originally posted by eludlow

Is it possible with cron to save a backup of a file to a different server or location?
Well ... this does not have anything to do with cron itself. cron is a timer daemon running in the background to run certain tasks specified at regular intervals. It does not really care what is being executed. Simply invoke a command or write a simple script which transfers the file to a remote location, and have cron runs it as usual. If you have multiple commands to execute in each iteration, writing a wrapper shell script allows you to include arbitrarily complicated logic in it.

There are a number of ways to transfer a file, depending on what server is available on your machine. I have used cron to regularly transfer backups with scp(1), also with a simple Perl script using the Net::FTP module, both invoked through a wrapper shell script which is executed by cron. Either way, that's still quite easy.
# 3  
Old 05-30-2004
Thanks for the reply!

I'm a total newbie to Unix, so is there a script available on the web I could download, and adapt a little?

Can CRON run any form of script? I could for example code something in PHP telling it to transfer?

Thanks,
Ed
# 4  
Old 05-30-2004
Quote:
Originally posted by eludlow
I'm a total newbie to Unix, so is there a script available on the web I could download, and adapt a little?

Can CRON run any form of script? I could for example code something in PHP telling it to transfer?
Yes, cron can run anything that can be executed on the command line. I am pretty sure if you have PHP installed as a command-line executable (rather than just an Apache handler which only contains a shared library) cron will be able to run a PHP script, although I don't know PHP myself. I use only Perl.

By the way, my Perl FTP script looks like the following:

Code:
#!/usr/bin/perl -w

# Transfer specified file with FTP

use Net::FTP;

my $ftp = Net::FTP->new('host.domain.com', Debug => 0);
$ftp->login("user", "password@host");
$ftp->cwd("/Documents/somewhere");
$ftp->put('manual.pdf');
$ftp->quit();

0;

There are also some related threads on this forum (some in FAQ) on automated file transfer. You may also search for them and see if you get any useful hints.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cron job - Need to run Cron every quarter at particular time

Hi, 1) If some job supposed to run on 1st of every month at 7 AM In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day? 2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct) And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies

2. Shell Programming and Scripting

Commented cron job -- cron monitoring

Hi I have a requirement to write a shell script,that will check the all commented job in cron job.Please help !! (2 Replies)
Discussion started by: netdbaind
2 Replies

3. Solaris

Cron job running even after cron is removed

Hi , I have removed a cron for particular user , but cron job seems to be running even after the cron entry is removed. The purpose of the cron was to sendmail to user ( it uses mailx utility ) I have restarted cron and sendmail service still user is getting mail alerts from the cron job. And... (4 Replies)
Discussion started by: chidori
4 Replies

4. UNIX for Advanced & Expert Users

cron job to extact lines from files to another file and ftp to new server

i have a text file in this format: which creates a new one everyday in the form of filename _zing__r200_2012_8_10_log.txt Fri Aug 10 07:29:17 EDT 2012, usera(192.168.0.245) to anotheruser: hey top, this is a private test Fri Aug 10 07:29:28 EDT 2012, anotheruser(192.168.0.245) to usera: got... (2 Replies)
Discussion started by: bkkid
2 Replies

5. Shell Programming and Scripting

Script that will be a cron job to export rrd files for cacti server

I wrote a quick little script that will eventually end up as a cron job to export rrd files for my cacti server. Here is the script: #!/bin/bash rm -rf /backup/cacti_xml/* cd /var/www/html/rra ls -1 *.rrd | awk '{print "rrdtool dump "$1" > /backup/cacti_xml/"$1".xml"}' | sh -x Is there... (5 Replies)
Discussion started by: TheBigAmbulance
5 Replies

6. UNIX for Dummies Questions & Answers

Keep Server Alive with Cron Job

Despite my best efforts, my media streaming server still dies sometimes and I am in a random place trying to ssh into the server to restart it on my cell phone after customers start calling.... I tried using google to track down a script that would do the following Every 5 min execute: sudo... (1 Reply)
Discussion started by: ajhalls
1 Replies

7. UNIX for Dummies Questions & Answers

Crontab keeps saving empty files of the job file.

Hey, MAILTO=cron@domain.ca */20 * * * * /usr/bin/wget http://list.domain.ca/admin/consume.php >/dev/nullthats what the crontab is setup todo, so basically every 20minutes it runs consume.php In my root directory, i'm getting files like this: consume.php consume.php1 consume.php2 i woke... (3 Replies)
Discussion started by: iarp
3 Replies

8. Solaris

cron job starts new cron proccess

I run cron in solaris 10 zone. One cron job which syncing files to nfs mounted on container, creates after finishing another cron proccess(/usr/sbin/cron), and after 100 existing cron proccesses next cron job will not start. It's too weird for me, I'm not able to solve this problem. Theoretically... (3 Replies)
Discussion started by: ron76
3 Replies

9. UNIX for Dummies Questions & Answers

Server moved, new IP, broken CRON job

Due to downsizing and attrition, I have inherited SysAdmin tasks, but unfortunately not all the required knowledge and skills came to me along with the assignment -> so I appreciate any advice and help ( be patient with my newbie terms and questions). We moved a central server and changed it's... (1 Reply)
Discussion started by: HikerLT
1 Replies

10. UNIX for Dummies Questions & Answers

CRON usage for CRON job

can anybody explain the usage of CRON for adding a cron job. please provide an example also for better understanding !!! Thanks (1 Reply)
Discussion started by: skyineyes
1 Replies
Login or Register to Ask a Question