Need to run a command from cron


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Need to run a command from cron
# 1  
Old 08-19-2010
Need to run a command from cron

How can I run the following command from cron?

tar -cvf /email_backup/email_bu_062110.tar /prod/email


# 2  
Old 08-19-2010
The following line in a user's crontab (edited with crontab -e) will run this daily at midnight. See man 5 crontab for details on the exact format of the lines.
Code:
0 0 * * * tar -cvf /email_backup/email_bu_062110.tar /prod/email

This User Gave Thanks to Corona688 For This Post:
# 3  
Old 08-19-2010
normally I give full path in cronjob always. And I guess you'd like to put the date in the filename. not always 062110.

Code:
0 0 * * * /usr/bin/tar -cvf /email_backup/email_bu_`date +\%m\%d\%y`.tar /prod/email

 
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 cannot run the command

Hi, I created this cron job for asterisk to send sms daily to a number #!/bin/sh #custom mod - send sms once a day, at 07:00. CRON_PATH="/etc/asterisk/gw/crontabs_root"; if ! grep 'gsm send sms' $CRON_PATH > /dev/null 2>&1 ;then echo "* 7 * * * asterisk -rx 'gsm send sms 1 7666... (4 Replies)
Discussion started by: jazzyzha
4 Replies

2. 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

3. Shell Programming and Scripting

Script for telnet and run one command kill it and run another command using while loop

( sleep 3 echo ${LOGIN} sleep 2 echo ${PSWD} sleep 2 while read line do echo "$line" PID=$? sleep 2 kill -9 $PID done < temp sleep 5 echo "exit" ) | telnet ${HOST} while is executing only command and exits. (5 Replies)
Discussion started by: sooda
5 Replies

4. Shell Programming and Scripting

Who -u gives different output if run from cron than if run from terminal?

If I run 'who -u' interactively or from a script invoked through bash in a tty on my Ubuntu 12LTS box I get an output like this: testuser pts/0 Dec 9 02:32 . 2163 (host.xx.yy) running the same through cron I get: testuser pts/0 2012-12-09 02:32 00:05 2163... (2 Replies)
Discussion started by: latimer
2 Replies

5. Shell Programming and Scripting

How to check if script is run via cron or manual=command line?

Hi all, I have a script that can be run via cron or via the command line. Is there any way that I can place something on the script to be able to distinguish/differentiate whether the script was run via a user in the command line or whether it was run from the cron? (3 Replies)
Discussion started by: newbie_01
3 Replies

6. Shell Programming and Scripting

Scheduling a command to run every 3 days through cron

Hello, I have to schedule a command to run on every 3 days. Whether the below cron entry will work? 0 3 */3 * * command Please help me out and thanks in advance! (6 Replies)
Discussion started by: Arunprasad
6 Replies

7. UNIX for Dummies Questions & Answers

Cron job to run a command from another dir?

I would like to setup a cron job to run a command from another directory. What is the best way to do this? The cron file is in a directory and the script I want it to run is in another directory. I tried doing this in the cron file: /location/of/command/run.sh But that did not work.... (2 Replies)
Discussion started by: Sepia
2 Replies

8. UNIX for Dummies Questions & Answers

cron does not appear to run

Hi everyone, I am having a problem with a cron, I am using Solaris 10 and need to run a php file every 5 minutes. I can run the file from the test user, but the cron does not seem to run. I do not see anything about it in /var/cron/log but see crons for other users running. What should I look... (10 Replies)
Discussion started by: atomicbits
10 Replies

9. UNIX for Dummies Questions & Answers

Please help me with the run-away cron jobs

I started a cron job on a cluster super computer. I am just a usual user over there and has no root power. The cron job was set by using "crontab -e". It excecutes a perl command every 20 minutes. I could use crontab -l or crontab -r to list or remove the cron job. However, I just found that I... (2 Replies)
Discussion started by: dedema
2 Replies

10. UNIX for Dummies Questions & Answers

Where does cron run from?

I have a script in the same directory as some files and directories im trying to tar up and I have it run in cron. Well it runs but says it can't find the directories, you need to be in the directory where the script is for it to work. Here is my cron and script its crappy but it does the trick =).... (3 Replies)
Discussion started by: kingdbag
3 Replies
Login or Register to Ask a Question