Operating System - HP-UX
1833883 Members
1501 Online
110063 Solutions
New Discussion

Re: search of variable name.

 
SOLVED
Go to solution
Patrice Blanchard_2
Frequent Advisor

search of variable name.

Hi,

what's the variable that keeps the day in HP-UX? Like crontab where 0 = sunday.

I'm running a script every day that updates data and send me an email but i only want to send an email if it's not during the weekend.

I know that i could modify the crontab but script is running other things that i need to run on weekends also.

I want to put a validation in the script to check the day and send the email if it's not sunday or saturday.

What's that variable?

Regards

PB
5 REPLIES 5
Mridul Shrivastava
Honored Contributor

Re: search of variable name.

Please refer the man pages of crontab for the same.

minute The minute of the hour, 0-59

hour The hour of the day, 0-23

monthday The day of the month, 1-31

month The month of the year, 1-12

weekday The day of the week, 0-6, 0=Sunday
Time has a wonderful way of weeding out the trivial
Enrico P.
Honored Contributor
Solution

Re: search of variable name.

Hi,
you can use the command:

DAY=`date "+%A"`

for set your day variable.

DAY=`date "+%A"`
echo $DAY
Monday


Enrico
James R. Ferguson
Acclaimed Contributor

Re: search of variable name.

Hi Patrice:

You can simply use:

# date '+%w'

This returns the day of the week beginning with one (1) for Monday and ending with seven (7) for Sunday.

See the manpages for 'date(1)'.

Regards!

...JRF...
Peter Nikitka
Honored Contributor

Re: search of variable name.

Hi,

from 'man strftime' on SUN:

%u Weekday as a decimal number [1,7], with 1 representing Monday

%w Weekday as a decimal number [0,6], with 0 representing Sunday.

So you are closest to crontab in using 'date +%w'

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Patrice Blanchard_2
Frequent Advisor

Re: search of variable name.

Thanks for all your help on this.

Regards

PB