Script runs fine manually but not in crontab


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script runs fine manually but not in crontab
# 1  
Old 05-28-2012
Script runs fine manually but not in crontab

Hello Guys,

I have scratched my head alot on this but couldn't find clue what's wrong. Can you please help me with this? My problem is as following.

1) When I manually execute following script it runs successfully with below output.

Code:
bash-3.00# more smssend
#!/bin/bash
echo -e "<Request MO="SMPPSMS-local" Operation="Set" Origin="PPAS">
<MSISDN>923455858076</>
<Version>1</>
<Message>ivr ocmp-bre is down, restarting bre
</>
</Request>"|/opt/EABfds/bin/FDSRequestSender -u sdpuser -p sdpuser 

bash-3.00# ./smssend 
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<Response>
<Result>Ok</Result>



But when I run the same script through crontab it does not run.

Code:
bash-3.00# crontab -l|grep smssend
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /export/home/fdsuser/IVR/smssend

Can somebody please identify what is wrong?

Regards,
Umar

Last edited by Scrutinizer; 05-28-2012 at 08:41 AM.. Reason: code tags
# 2  
Old 05-28-2012
all of your script(smssend) is this?
what is the "</Response>", is the output after executed the your script by crond ?
# 3  
Old 05-28-2012
Hello ygemici,

Yes, smssend is all of my script.

In my earlier post "</Respone>" was a typo in crontab entry. Correct one is as below.

Code:
bash-3.00# crontab -l|grep smssend
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /export/home/fdsuser/IVR/smssend 



When I execute smssend manually, below is the successful response.

Code:
bash-3.00# ./smssend 
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<Response>
<Result>Ok</Result>

I am guessing crontab is unable to run my script because its unable to parse above output. But I am not sure though.

Regards,
Umar



Last edited by Scrutinizer; 05-28-2012 at 08:42 AM.. Reason: code tags
# 4  
Old 05-28-2012
maybe your script runs fine ?
did you check the crond logs?
Code:
..........
crond[XXXX]: (root) CMD (XXXXXXXXXX)

and can you try like this ?
Code:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /export/home/fdsuser/IVR/smssend >> /tmp/smssend_results

# 5  
Old 05-28-2012
I think this is to do with your profile..
try to source your .profile or any other custom profile in your smssend script
# 6  
Old 05-28-2012
Couldnt find crond logs on my machine and doing below also didn't help.

Code:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /export/home/fdsuser/IVR/smssend >> /tmp/smssend_results

# 7  
Old 05-28-2012
check the permission on file you are trying to execute from cron. sometimes it gives lots of pain.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Job runs manually, doesn't work in crontab

I have a script (/home/admin/run_bkup.sh) that I can run manually to kick off an executable job. I want to run it in crontab, but it doesn't work. Here's the script: shell=/bin/bash today=$(date +"%m-%d-%y") /opt/CPsuite-R77/fw1/bin/upgrade_tools/upgrade_export mgt-svr-bkup-$today << EOF y... (18 Replies)
Discussion started by: df08388
18 Replies

2. Shell Programming and Scripting

Script runs manually, but not from cron

Hi, I "borrowed" a script I found online, to start a SAP router application on a Solaris 11 (SPARC) server. The script runs fine when calling it manually, but when I schedule it to run from cron, it doesn't. I don't see any warning or failure messages anywhere, just nothing happens. ... (11 Replies)
Discussion started by: bredman
11 Replies

3. UNIX for Dummies Questions & Answers

Script runs manually but not from crontab in UNIX

Hi Guys, I am executing the script called Delet.sh manually it is successfully completing the task but it is failing to run vi cron tab, I tried to pass PATH & .profile before execution but no luck, Any suggestions? Script below #!/usr/bin/ksh #set -x # Purpose : Delete folders file from... (9 Replies)
Discussion started by: Anilsa77
9 Replies

4. Shell Programming and Scripting

Script runs good manually but failing via crontab

Hello Gurus, I have written small script which will start the given service if its stop .Its running fine when manually executed but its unable to run from crontab. #!/bin/bash SERVICENAME=rsyslog service $SERVICENAME status > /dev/null SYSLOGSTATUS=`echo $?` COUNT=0 THRESHOLD=3 if ... (4 Replies)
Discussion started by: kapil514
4 Replies

5. Shell Programming and Scripting

Script runs in command-line fine but times out in CRON?

Hi, I have a script that seems to run to completion when in the command-line, but when it is run using the cron, it seems to time out. They both start and run fine, but on the CRON it stops prematurely. The script hits an API every few seconds and grabs data. Does anyone have any idea on... (4 Replies)
Discussion started by: phpchick
4 Replies

6. Shell Programming and Scripting

Part of the Shell script is not running via crontab, runs fine manually

Hello Team, As a part of my job we have made a script to automate a service to restart frequently. Script having two functions when executing it's should find the existing service and kill it, then start the same service . Verified the script it's working fine when executing... (18 Replies)
Discussion started by: gowthamakanthan
18 Replies

7. Shell Programming and Scripting

Script runs manually but not correctly from crontab

Hello all, I'm new here and have a question if you don't mind helping me. I have a script that will work if I kick if off manually but not from Cron. My cron entry is this: 05,20,35,50 * * * * /scripts/status.sh > /dev/null 2>&1 The first script (works fine) is this: #!/bin/sh # #... (14 Replies)
Discussion started by: hs3082
14 Replies

8. Shell Programming and Scripting

Script runs manually but not correctly from crontab

Hi all I have this inside a shell script (bash): cd DIRECTORY find . -maxdepth 1 | sed 's#./##' | /usr/bin/xargs -I '{}' chown -Rv '{}' /DIRECTORY/'{}' All the directories in this location are named after usernames, so it simply sets the owner to that of the username of the folder. It... (5 Replies)
Discussion started by: fakesy
5 Replies

9. Shell Programming and Scripting

Script Runs fine but not giving any output

Hi, My script is running with no erros but not giving any output can anyonehelp. #!/bin/ksh . /home/application/bin/application.env OUTFILE=Result.txt PROD_PASSWORD=`${GET_PWD} -f ${PWD_FILE_PATH} -s ${PROD_SERVER} -u ${PROD_USER}` echo "1)To get the book last loaded details " read... (7 Replies)
Discussion started by: jagadish_gaddam
7 Replies

10. Shell Programming and Scripting

Script runs fine, but not in a cron

Okay, I have the following script that runs fine from a command line as well as an executable .sh file. It just moves any file/folder with movie* in the name to a folder called _Movies. The issue I'm running into is when it's call from a cron. find /mnt/HD_a2/BT/complete -iname "movie.*" -exec... (4 Replies)
Discussion started by: sammyk
4 Replies
Login or Register to Ask a Question