Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


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

Rep: Reputation: 38
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);

#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:

# 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, 03:49 PM   #2
jim mcnamara
Registered: May 2002
Posts: 964

Rep: Reputation: 36
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:
# use /bin/sh to run commands, no matter what /etc/passwd says
# mail any output to `paul', no matter whose crontab this is
# 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"


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 02:34 AM
Cron Jobs XaViaR Linux - General 1 06-23-2005 06:57 PM
cron jobs working2hard Linux - Software 0 07-28-2004 05:31 PM
CRON Jobs scottpioso Linux - Software 63 11-28-2003 06:45 PM
cron jobs Zyanid Linux - Software 0 08-27-2002 05:10 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:25 AM.

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