[Solved] Shell script not working in crontab


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] Shell script not working in crontab
# 1  
Old 02-15-2013
[Solved] Shell script not working in crontab

Hi

Iam running below script in crontab but its not working.

Code:
#!/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 is not generating with cron


The above will script will do

1) Indivisual backfiles will stored in bngbackup directory after running expect command --- upto this code is working

2) Iam compressing the bngbackup directory with below command

Code:
tar -cf bngbackup.tar bngbackup  ;gzip bngbackup.tar

its not working in cron.what wrong with my code.can any body help . Iam running the code on solaris 10 OS.

Last edited by surender reddy; 02-15-2013 at 11:42 AM..
# 2  
Old 02-15-2013
Did you look in your cron logs?
What is the expect doing here? Does that work with cron?
# 3  
Old 02-15-2013
Are you capturing the log of the script any where?

I guess , the gzip may not be available in path!!!..

Do this,issue below command:

$ which gzip

copy the above path and use it in the script , instead of using gzip directly.
This User Gave Thanks to panyam For This Post:
# 4  
Old 02-15-2013
Hi,

Expect is working with cron. it will store the backup files in bngbackup directory

after this only problem is coming.

the below command is not working in cron

Code:
tar -cf bngbackup.tar bngbackup  ;gzip bngbackup.

but while executing manually bngbackup.tar.gz was created
# 5  
Old 02-15-2013
looks like panyam is correct: You either have to set PATH in your script or give the path to your commands as you did with expect... For gzip is not standard on all UNIX and you did not say what OS you were using, this may very well be the culprit and good candidate for "not found" messages...
# 6  
Old 02-15-2013
Hi

I added path in the script. Now file was created using cron

Code:
/usr/bin/tar -cf bngbackup.tar bngbackup  ;/usr/bin/gzip bngbackup.tar

Tnx to all
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script not working via crontab

Hi, I have written one script which is connecting to the the database and generating one CSV, it is running fine when i ran it manually though it is throwing any warning but CSV is generating and working fine but same script when i have configured in crontab not working and giving error, kindly... (1 Reply)
Discussion started by: ash1234
1 Replies

2. Shell Programming and Scripting

Script not working via crontab

Hi, I have written one script which is connecting to the the database and generating one CSV, it is running fine when i ran it manually though it is throwing any warning but CSV is generating and working fine but same script when i have configured in crontab not working and giving error, kindly... (6 Replies)
Discussion started by: ash12345
6 Replies

3. Red Hat

Script not working if crontab scheduled

Hi all, I'm working to a script with /bin/bash shebang. The script works perfectly if I run from command line. The script runs under a non root user and inside the commands are set with sudo command in a such a way they can be run under root, for example (first rows of the script):... (5 Replies)
Discussion started by: idro
5 Replies

4. UNIX for Dummies Questions & Answers

Script is not longer working in the crontab

This is the crontab it is supossed to be running everyday but it didnt 5 0 * * * /export/app/CO/opge/scr/Informe_parametros_colombia.ksh >/dev/null 2>&1 Inside the above script connects to a database and extract data to a flat file, manually i run the script at about 2 a.m. and Works OK,... (6 Replies)
Discussion started by: alexcol
6 Replies

5. Shell Programming and Scripting

[Solved] Simple script not working- for loop

Hi all, Please guide me writing this script Follwing is the file which I have created, which contains the files to be copied. cat system1-dr.txt /etc/passwd /etc/shadow /etc/group /etc/vfstab /etc/profile /etc/default/init /etc/shells /etc/dfs/dfstab /etc/dfs/sharetab... (11 Replies)
Discussion started by: manalisharmabe
11 Replies

6. UNIX for Advanced & Expert Users

[Solved] Crontab not launching script

Hi all, i have the following script #!/bin/sh for i in `ps -leaf --cols 1024 | grep LogUser | grep -v grep | awk '{print $4}'`; do echo $i kill -15 $i; done; but it seems that the crontab its sciping this script,i configured corntab as following */30 * * * root... (2 Replies)
Discussion started by: charli1
2 Replies

7. Shell Programming and Scripting

Script not working in crontab

Hi I have created a script. Which i have configured in cron to make it run in every 2 min. But script is not running. If I checl the cron log at /var/cron/log .it shows its running in every 2 min. Below is the command which i configured in crontab. But I am not able to find the way so that... (9 Replies)
Discussion started by: nandan8a
9 Replies

8. Shell Programming and Scripting

My script stops working when using crontab

I have made a shell script(/bin/sh) that starts a perl script (that I haven't made my self) that's starts a ssh session. The ssh session uses a private/public key to login so no password is needed. The Perl script works perfect. But when I put it in a cronjob (crontab) the ssh connection asks... (6 Replies)
Discussion started by: splinter_cell
6 Replies

9. Shell Programming and Scripting

Expect Script Not working with Crontab

I have the following expect script sitting on a Linux box. === #!/usr/bin/expect -f # # backup.expect # # Expect script to backup a firewall via a SSH session # # set firewall set username set password set prompt set filename match_max 50000 spawn ssh -l... (2 Replies)
Discussion started by: alagondar
2 Replies

10. Shell Programming and Scripting

Script is not working when put in crontab

Hi there, this is part of my script: /usr/bin/cd /u01/oradata /usr/bin/cp `/bin/ls -1 . |grep -v "^DIMStemp01.dbf$" | grep -v "^DIMSts01.dbf$"|grep -v "^DIMStects01.dbf$"` /backup It's working fine when I manually run on telnet session. /bin/ls -1 . -- to list all the files inside... (2 Replies)
Discussion started by: *Jess*
2 Replies
Login or Register to Ask a Question