Script runs manually, but not from cron


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script runs manually, but not from cron
# 1  
Old 05-27-2016
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.

Here is the relevant part of the script;

Code:
 # Set Variables
ROUTDIR="/usr/sap/saprouter";
DNAME="p:CN=SERVERNAME, OU=0000xxxxxx, OU=SERVERNAME, O=SAP, C=DE";
# End Variables
#
/usr/sap/saprouter/./saprouter -r -R "$ROUTDIR/saprouttab" -K "$DNAME" &
exit

Here is the cron entry;

Code:
 00 10 * * 1-5 /usr/sap/saprouter/scriptname

Any ideas?

Thanks in advance.



Moderator's Comments:
Mod Comment Please use code tags as required by forum rules!


Bryan

Last edited by RudiC; 05-27-2016 at 08:08 AM.. Reason: Added code tags.
# 2  
Old 05-27-2016
A background process finishes when its parent does unless disowned or nohupped.
# 3  
Old 05-27-2016
Is this a task, that must be run regularly, or is it a service, that should be run always and the cron-job is only to make sure it starts again in case it terminates?

If it is the latter, a service definition would be better. I myself have no knowledge how a service is set up in Solaris.

To just debug your cron-entry after you followed Rudis advice, I suggest doing redirecting of the output:

Code:
 00 10 * * 1-5 nohup /usr/sap/saprouter/scriptname >/tmp/saprouter.log 2>&1

Then you have a logfile where to look for errors.
# 4  
Old 05-27-2016
Thanks for your prompt responses.

This is a service that only needs to run for 15 minutes each day. There is another cron job to stop this at 10:15.

This is the output from the log file;

Code:
# more /tmp/saprouter.log
*****************************************************************************
*
* ERROR SNC processing failed:
* SncInit
*
* TIME Fri May 27 13:00:00 2016
* RELEASE 745
* COMPONENT NI (network interface)
* VERSION 40
* RC -17
* MODULE /bas/745_REL/src/base/ni/nisnc.c
* LINE 553
* DETAIL NiSncInit: sncrc=-1
* COUNTER 4
*
*****************************************************************************

trcfile dev_rout


According to SAP, this seems to indicate a problem with authentication. However, if I run the script manually, there is no error...

I should say, I also revised the crontab entry to include "nohup";

Code:
00 13 * * 1-5 nohup /usr/sap/saprouter/scriptname > /tmp/saprouter.log 2>&1




Moderator's Comments:
Mod Comment Better, but not quite there. Use code tags for data or output as well!

Last edited by RudiC; 05-27-2016 at 12:18 PM.. Reason: More information; RudiC: Corrected code tags
# 5  
Old 05-27-2016
Maybe the program needs a "terminal" attached to the process.

You may try to use it via screen in detached mode.

Code:
00 10 * * 1-5 screen -d -m /usr/sap/saprouter/scriptname

Probably you must get screen somehow installed first. When screen with the program is running, you can connect to it via screen -r and disconnect with [Ctrl] + [a] then [d].
# 6  
Old 05-27-2016
I Installed the "screen" package and updated cron as follows;

Code:
32 13 * * 1-5 screen -d -m /usr/sap/saprouter/scriptname > /tmp/saprouter.log 2>&1

Service still not starting and more oddly, no entry at all in the /tmp/saprouter.log file!

Last edited by bredman; 05-27-2016 at 10:19 AM.. Reason: Added code tags
# 7  
Old 05-27-2016
I assume the same error still happens. The log output is empty because screen itself does not output anything. The program does.

You may add sleep 120 at the end of the script /usr/sap/saprouter/scriptname (before exit!) and connect via screen -r as described above. Now you should see the error.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Execution problem with Cron: Script works manually but not w/Cron. Why?

Hello gurus, I am making what I think is a simple db2 call from within a shell script but I am having difficulty producing the desired report when I run the script shown below from a shell script in cron. For example, my script and the crontab file setup is shown below: #!/bin/ksh db2... (3 Replies)
Discussion started by: okonita
3 Replies

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

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

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

5. Shell Programming and Scripting

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. bash-3.00# more smssend #!/bin/bash echo -e "<Request... (16 Replies)
Discussion started by: umarsatti
16 Replies

6. Shell Programming and Scripting

Shell Script runs good manually but not through Cron tab

Hello Every one, I have a shell script which is running fine manually, but its giving me hard time when running tru cron job. :wall:. Am using #!/usr/bin/ksh >echo $SHELL /usr/bin/ksh Cron Job is as below, it execues but dosent do what i want it to do. 47 15 * * *... (1 Reply)
Discussion started by: naren.chowdhary
1 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. Solaris

SFTP errorcode 1 when run on cron but runs manually

I am trying to run a sript on cron to SFTP data to a company. Private and public keys are set up. When I run this manully it works fine, however it was failing when run on cron. I have narrowed down the problem - it fails at the code that says if the error code is 0 then continue . . . I... (2 Replies)
Discussion started by: Heidi.Ebbs
2 Replies

10. Shell Programming and Scripting

Can run script Manually, but not through Cron?

Hi all, I have a main script (called OracleCleanup) that runs some sql queries. that runs off a wrapper script which contains the sources for the login information and and JOB_HOME (the script is below). When I schedule this job in the cron the log says that it cannot open my list file, which... (4 Replies)
Discussion started by: MadHatter
4 Replies
Login or Register to Ask a Question