Crontab and shell pb


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Crontab and shell pb
# 1  
Old 04-07-2008
Crontab and shell pb

Hi,

i try to execute the following in a crontab file and it doesn't work while the same line is OK on the Unix (AIX) shell command line.
Code:
42 15 * * 1 > /users/notes01/tata.${date +"%d%m%Y"}

it seems to be a pb related to date flags expression but i can't see why , somebody have an idea ?

regards
Christian

Last edited by Yogesh Sawant; 04-08-2008 at 05:41 AM.. Reason: added code tags
# 2  
Old 04-07-2008
The reason is that "> file" is a redirection. A redirection makes only sense if there is a process which output can be redirected. If you execute the redirection on the commandline then this process is the shell itself. If you execute it from crom there is no such process and hence the construct doesn't make any sense.

I hope this helps.

Btw., what was your intention? What do you want to achieve? Maybe we can find a solution for this instead of telling you why your statement won't work.

bakunin
# 3  
Old 04-07-2008
touch will create an empty file for you, at the expense of a process (but in crontab you need that process, I guess).
# 4  
Old 04-08-2008
At the beginning i wanted to do :
Code:
22 15 * * 1 mv /users/notes01/toto /users/notes01/toto.${date +"%d%m%Y"}

even i changed the "date" statement , each time the flags are not taken into account , how i can do this without doing the same into a shell script ?

regards

Christian

Last edited by Yogesh Sawant; 04-08-2008 at 05:42 AM.. Reason: added code tags
# 5  
Old 04-08-2008
Make it into a script, trust me on this.

Your syntax for getting the date is wrong, those should be round parentheses.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problems with a crontab shell

Hi everyone, can you help me ?, I have the following shell: DIR="/backups/backdata" DIR_2="/BACKOPENF/database" LOG="/backups/logs/oracle_backup.log" EXP_LOG="/backups/logs/Exp`date +%Y%m%d%H%M%S`.log" EXP_FILE="Exp`date +%Y%m%d%H%M%S`.dmp" HOLD_DAY=1 # String de conexion... (4 Replies)
Discussion started by: Manolo
4 Replies

2. Shell Programming and Scripting

Issue in running shell script in crontab

I'm having a shell script which has to be run only once at the specified time. Shell script is like following, #!/bin/bash db2 connect to XXX > connection_status.txt This script is scheduled in crontab as following, 50 4 8 5 0 sh script.sh scheduled script is run at the specified time... (1 Reply)
Discussion started by: Rajkumar Gandhi
1 Replies

3. Shell Programming and Scripting

[Solved] Shell script not working in crontab

Hi Iam running below script in crontab but its not working. #!/bin/sh cd /Scripts /usr/local/bin/expect -f /Scripts/bng_backup.exp /Scripts/data.txt tar -cf bngbackup.tar bngbackup ;gzip bngbackup.tar when iam running manually the output file is generating..but bngbackup.tar.gz file... (5 Replies)
Discussion started by: surender reddy
5 Replies

4. Shell Programming and Scripting

Wants to change shell script into crontab

Hi friends, Actually i wrote many scripts in korn shell for time saving activity in storage domain. But every week i am spending some time for the running of script. So every Monday i wants to run my scripts automatically. So corn will be helpful according to my friend's opinion. But I don't... (5 Replies)
Discussion started by: Mahendranath
5 Replies

5. Shell Programming and Scripting

use crontab for a shell script..

hi, i have shell script which checks for service running on platform, if service is receiving calls, then do nothing if service is not receiving calls, then stop the service i want to run this script in 2 timeslots. i.e. in the day from 9 am to 5 pm it should run every 10 minutes and ... (2 Replies)
Discussion started by: gauravah
2 Replies

6. Shell Programming and Scripting

Change crontab from shell script

Hi All, I have scheduled a script to run every five minutes through crontab. If there is any issue with the script which may need manual intervention, I have used the mailx commands. But at the same time, I would want the cron to be disabled until the issue is resolved. Once things are fine,... (2 Replies)
Discussion started by: adi_2_chaos
2 Replies

7. Shell Programming and Scripting

Adding a job to crontab via shell script

Is it possible to add a job to crontab with a shell script? The existing jobs in the crontab should exist as it was. The new job should be appended. Also, the crontab file is /var/spool/cron/root. (1 Reply)
Discussion started by: proactiveaditya
1 Replies

8. Shell Programming and Scripting

Can we edit crontab using a shell script

Hi, Can some one tell me if we can configure the jobs in crontab using a shell script. I know it can be done easily by using "crontab -e", but i just want to know whether we can add a job into the crontab using a shell script. If it can be done, plz suggest the procedure to do it. If it... (6 Replies)
Discussion started by: rudrarajumk
6 Replies

9. Shell Programming and Scripting

How do i run a shell script without crontab.

Hi Folks, Could you please suggest me how to run a shell script on a solaris env without using crontab. I am actually trying to write a shell script which will grep "WORD" in the logfile andd sends a email.Thanks in advance. Thanks Sandeep. (3 Replies)
Discussion started by: sandeep anand
3 Replies

10. Shell Programming and Scripting

no shell invoked in crontab

Hi all, I am trying to run a script in crontab but I receive the email below. Note the empty variable SHELL. Apparently cron doesn't invoke a shell. That explains the errors in the script it is trying to execute. Anyone know what maybe wrong? Subject: Output from cron job... (3 Replies)
Discussion started by: ivanushka
3 Replies
Login or Register to Ask a Question