![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| 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 06:44 AM |
| Return of EXIT status ( $? ) | ZINGARO | HP-UX | 1 | 03-12-2008 07:07 AM |
| Verify scp return status | new2ss | Shell Programming and Scripting | 2 | 06-28-2006 10:04 PM |
| return ftp status | blt123 | Shell Programming and Scripting | 12 | 07-21-2005 05:48 AM |
| Return status... | Shaz | Shell Programming and Scripting | 7 | 11-19-2002 06:35 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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. |
|
||||
|
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. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|