Well, what does it do?  So you can see from the logs that cron executes 
the file, but doesn't appear to do anything?

My cron sends me an email on each execution (if there is any output from 
the script).
Put more 'echo' commands in to troubleshoot, so that something prints to 
STDOUT | ERR whenever run.
If there's a problem (like it can't find the ping command or your backup 
script) it should at least tell you that.

Script should probably have the full path name for the ping_check.txt 
file, so you know where to look for it.  (ie. /tmp/ping_check.txt).  
Make sure cron has permission to write the file.

If there is a problem with cron not finding the path's to executables, 
put  a PATH in the crontab.

=========== crontab 
============================================================
PATH=/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

# m h  dom mon dow   command

*/5 * * * *    /usr/local/bin/ping.sh >2&1            (.. or > /dev/null 
2>&1 later to get rid of the annoying emails)
=============================================================================



On 01/04/2011 04:07 PM, Raymond Norton wrote:
> How should this script be run from cron? I tried appending > 
> /dev/null, but can't get it to run like it does from the command line.
>
>
>
>
> On 01/04/2011 09:14 AM, Raymond Norton wrote:
>> Took a couple hours of pounding away, but yeah, the script works 
>> perfectly with my backup solution!
>>
>>
>> Thanks
>>
>>
>>
>>
>>
>>
>> On 01/03/2011 03:56 PM, John Hawley wrote:
>>> #!/bin/bash
>>>
>>> HOST="windowshostname"
>>>
>>> CMD="ping -c1 $HOST"
>>> CMD_RET=`$CMD`
>>> # echo $CMD_RET
>>> NOWDATE=`date +%Y%m%d`
>>>
>>> if [ -f ping_check.txt ];
>>> then
>>>      FILEDATE=`cat ping_check.txt`
>>> else
>>>      FILEDATE=0
>>> fi
>>>
>>> if [ $NOWDATE -ne $FILEDATE ];
>>> then
>>>      if [[ $CMD_RET =~ ", 0% packet loss" ]]
>>>      then
>>>           echo "$HOST pinged ..."
>>>           echo $NOWDATE > ping_check.txt
>>>         # run backup script
>>>      else
>>>           echo "$HOST did not ping ..."
>>>      fi
>>> fi
>>>
>>> exit
>>>
>>>
>>>
>>> On 01/03/2011 03:04 PM, Raymond Norton wrote:
>>>> Yes, it will have the same address . I would prefer to run it from 
>>>> the backup server, but am open to anything that is simple.
>>>>
>>>>
>>>> ----- "Justin Krejci" wrote:
>>>> > Does the windows XP machine always have the same IP address or at 
>>>> least on the same subnet as the backup server when it is online?
>>>> >
>>>> > Can you possibly have the Windows XP host run a script 
>>>> automatically when it is online that will trigger the backup process?
>>>> >
>>>> > -----Original Message-----
>>>> > *From*: Raymond Norton <admin at lctn.org 
>>>> <mailto:Raymond%20Norton%20%3cadmin at lctn.org%3e>>
>>>> > *Reply-to*: TCLUG Mailing List <tclug-list at mn-linux.org>
>>>> > *To*: tclug-list at mn-linux.org <mailto:tclug-list at mn-linux.org>
>>>> > *Subject*: [tclug-list] script help
>>>> > *Date*: Mon, 03 Jan 2011 14:21:21 -0600
>>>> > *Mailer*: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) 
>>>> Gecko/20100423 Thunderbird/3.0.4
>>>> >
>>>> >
>>>> I need to come up with a shell script that will launch another script
>>>> when a specific host is detected on the network. This is for an network
>>>> backup system. The host is always off-line when the back up runs at the
>>>> night and I want to fire the backup off when it comes back on-line.
>>>>
>>>> The script would run on the backup server as a cron job, and needs to
>>>> call the backup script only once per day.
>>>>
>>>> The backup server is Linux. The host is Windows XP.
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
>>>> tclug-list at mn-linux.org  <mailto:tclug-list at mn-linux.org>
>>>> http://mailman.mn-linux.org/mailman/listinfo/tclug-list
>>>>    
>>>>
>>>> > --
>>>> > This message has been scanned for viruses and
>>>> > dangerous content by *MailScanner* 
>>>> <http://www.mailscanner.info/>, and is
>>>> > believed to be clean.
>>>> > _______________________________________________ TCLUG Mailing 
>>>> List - Minneapolis/St. Paul, Minnesota tclug-list at mn-linux.org 
>>>> http://mailman.mn-linux.org/mailman/listinfo/tclug-list
>>>>
>>>> -- 
>>>> Raymond Norton
>>>> LCTN
>>>> Ecclesiastes 7:21-22
>>>>
>>>>
>>>> _______________________________________________
>>>> TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
>>>> tclug-list at mn-linux.org
>>>> http://mailman.mn-linux.org/mailman/listinfo/tclug-list
>>>>    
>>>
>>> -- 
>>> This message has been scanned for viruses and
>>> dangerous content by *MailScanner* <http://www.mailscanner.info/>, 
>>> and is
>>> believed to be clean.
>>>
>>>
>>> _______________________________________________
>>> TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
>>> tclug-list at mn-linux.org
>>> http://mailman.mn-linux.org/mailman/listinfo/tclug-list
>>>    
>>
>> -- 
>> This message has been scanned for viruses and
>> dangerous content by *MailScanner* <http://www.mailscanner.info/>, 
>> and is
>> believed to be clean.
>>
>>
>> _______________________________________________
>> TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
>> tclug-list at mn-linux.org
>> http://mailman.mn-linux.org/mailman/listinfo/tclug-list
>>    
>
>
> _______________________________________________
> TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
> tclug-list at mn-linux.org
> http://mailman.mn-linux.org/mailman/listinfo/tclug-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mn-linux.org/pipermail/tclug-list/attachments/20110104/cabab37d/attachment.htm