![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 's | manas6 | UNIX for Dummies Questions & Answers | 0 | 06-05-2008 03:44 AM |
| Return of EXIT status ( $? ) | ZINGARO | HP-UX | 1 | 03-12-2008 04:07 AM |
| Verify scp return status | new2ss | Shell Programming and Scripting | 2 | 06-28-2006 07:04 PM |
| return ftp status | blt123 | Shell Programming and Scripting | 12 | 07-21-2005 02:48 AM |
| Return status... | Shaz | Shell Programming and Scripting | 7 | 11-19-2002 03:35 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Terminal And Cron Job Return Different Status Code
Dear All,
I want to write a shell script to test the server is running or not. The method is pinging the server and examine the status code. the script: #/bin/tcsh ping -c 3 host if ($? != 0) then actionA endif This script work fine in terminal. The status code is 0 when the host is running and 2 when the host is down. But when I run the script in cron job, the status code is only returned in 1, no matter the host is up or down. Did I do something wrong in the script? Thanks for your attention and help. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
where is ping?
add an "echo $PATH" at the beginning of your script, make sure ping is in the path when run as a cron job. Also, check your individual system and see what the default shell is when cron in running. Be explicit on your shell in the first line of the script with a "#!/usr/bin/sh" Here's what I am thinking - if PATH isn't right, ping won't be found, returning an error code of 1. if you are running some weird shell that is different than the interactive one, that also could cause the format for the if the be wrong. |
|||
| Google The UNIX and Linux Forums |