Kill via Cron...
mcoyles
mcoyles at horbury.wakefield.sch.uk
Tue Apr 20 10:24:58 UTC 2010
>>On 20/04/2010 08:52:58, mcoyles wrote:
>> Morning all - on FreeBSD 7.1 (for various reasons - don't ask)
>> Am attempting to run the following via cron but it keeps erroring out:
>>
>> kill -9 `ps ax | grep backup | grep -v grep | awk '{print $1}'` && kill -9
>> `ps ax | grep dump | grep -v grep | awk '{print $1}'`
>>
>> *snip*
>>
>> Works OK from commandline - what do I need to change to make this cronable??
> The usual problem is that the environment under cron is not set up
> anything like the way it is for an interactive session. Particularly
> the PATH. Either write you command as a small shell script and setup
> PATH within it, or use fully qualified names for all commands.
>
> Your command is probably better expressed as:
>
> /bin/pkill -9 'backup|dump'
Hi Matthew - cheers for that, I always forget the lack of common path in cron *sigh*
Anyhoo, there are multiple instances of backup and dump coming back in ps -ax... your
suggested command appears to only kill off the first instance? Have used my commands
above in cron now using full path reference as per your advice - just waiting for the
clock to click round to 11.30 here for them to run...
Cheers...
Marci
More information about the freebsd-questions
mailing list