Operating System - HP-UX
1748226 Members
4645 Online
108759 Solutions
New Discussion юеВ

New to UNIX, need help with script

 
SOLVED
Go to solution
James R. Ferguson
Acclaimed Contributor

Re: New to UNIX, need help with script

Hi (again):

A better solution to your problem may be to add a one-line patch at line-388:

...
385 # Been there before but have we exceeded to INCR value? Note: we may
386 # be at 99% so the script will repeat.
387
388 [ -z "${INCR}" ] && INCR=${DEFINCR} #...patch...
389 LASTVALUE=$(echo $BEENTHERE | awk '{print $2}')
390 if [ $((LASTVALUE + INCR)) -le $PERCENT ]
...

This resets the default increment if it isn't defined. Now you can follow the documentation for the 'diskspace.conf' layout exactly.

Regards!

...JRF...
Jarheadatheart
Regular Advisor

Re: New to UNIX, need help with script

James, one last thing. How would I set that to a cronjob? I can't set the cron to run as
/usr/local/bin/diskspace.sh -e "me@me.org"

Can I?
Jarheadatheart
Regular Advisor

Re: New to UNIX, need help with script

I apologize for my ignorance. I am VERY new to UNIX.
James R. Ferguson
Acclaimed Contributor

Re: New to UNIX, need help with script

Hi (again):

> How would I set that to a cronjob? I can't set the cron to run as
/usr/local/bin/diskspace.sh -e "me@me.org"

For example:

00,10,20,30,40,50 * * * * /usr/local/bin/diskspace.sh -e"me@me.org"

...would run the process every 10-minutes after every hour on every day of the week, etc.
There is more information in the 'crontab' manpages. You're doing fine :-)

Regards!

...JRF...
Tom Ward_1
Honored Contributor

Re: New to UNIX, need help with script

You can use
/usr/local/bin/diskspace.sh -e "me@me.org"
as your command in the crontab entry.

If your scirpt has any output you may want to add
> /dev/null
to the end of the command so you don't get mailed from cron every time it runs.
If there is error output cron will still mail that.
Jarheadatheart
Regular Advisor

Re: New to UNIX, need help with script

Thanks... I have got the times/dates portion of cron down I think! HAHAHA!

So I can in fact run it like that. ok.

And the >/dev/null will make it only send me an e-mail if the script finds something?
Jarheadatheart
Regular Advisor

Re: New to UNIX, need help with script

would the entry be >>/dev/null 2>&1 or just >>/dev/null
James R. Ferguson
Acclaimed Contributor

Re: New to UNIX, need help with script

Hi:

> And the >/dev/null will make it only send me an e-mail if the script finds something?

You don't need to add that in this case. By default, 'cron' creates mail and sends it to the user's crontask _IF_ either STDOUT and/or STDERR has not been redirected (to a file).

Regards!

...JRF...
Jarheadatheart
Regular Advisor

Re: New to UNIX, need help with script

ah. Ok, thanks James!
Jarheadatheart
Regular Advisor

Re: New to UNIX, need help with script

Thanks a lot guys!