LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-04-2003, 04:00 PM   #1
bkeating
Member
 
Registered: Mar 2002
Location: San Francisco, CA
Distribution: Open/FreeBSD, Gentoo, SuSE
Posts: 511

Rep: Reputation: 30
cron jobs - tar scp in one line?


I'd like to setup a cron job set to go off ont he first of every month at 5am. There are two steps that I'd like to put into this cron but the FreeBSD mannual is rather limiting on information.

Steps I need to automate via cron:

1). tarball a directory
2). copy it to an alternative box without prompting for password.

Since tarballing locally and THEN scp'ing it would be to complicated for something so simple, this is what I want the cron job to do (this cron job would be on the machine that will STORE the tarball);

Code:
#ssh user@[destination] "tar cvplf - /" > /local/path/to/store/archive.tar
now ssh will prompt for a password.. and a while ago i found out how to setup the ssh.auth er whatever, which took like 2 seconds but I did not save those notes to my diary. Can someone help me out with this?

additionally, would this be a valid cron job entry for what i want:

Code:
# 5 AM on the firt of each month, reach out to the web server and store a backup locally
0 5 1 * * /usr/bin/ssh user@[destination] "tar cvplf - /" > /local/path/to/store/archive.tar
Any guidence would be wonderful. I will be sure to record these notes down in my diary file this time!
 
Old 11-04-2003, 04:49 PM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 34
Your crontab entry for the command can be the name of a shell script file,
instead of trying to write a very complex one-liner.

From crontab help:
Quote:
EXAMPLE CRON FILE
# use /bin/sh to run commands, no matter what /etc/passwd says
SHELL=/bin/sh
# mail any output to `paul', no matter whose crontab this is
MAILTO=paul
#
# run five minutes after midnight, every day
5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
# run at 2:15pm on the first of every month -- output mailed to paul
15 14 1 * * $HOME/bin/monthly
# run at 10 pm on weekdays, annoy Joe
0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%
23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday"
5 4 * * sun echo "run at 5 after 4 every sunday"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
scp does not work with cron jobs yogendrarawat Linux - Newbie 2 09-15-2005 03:34 AM
Cron Jobs XaViaR Linux - General 1 06-23-2005 07:57 PM
cron jobs working2hard Linux - Software 0 07-28-2004 06:31 PM
CRON Jobs scottpioso Linux - Software 63 11-28-2003 07:45 PM
cron jobs Zyanid Linux - Software 0 08-27-2002 06:10 AM


All times are GMT -5. The time now is 03:46 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration