HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- shell script with date logic
Operating System - HP-UX
1830939
Members
1595
Online
110017
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2002 07:09 AM
09-27-2002 07:09 AM
I have a script named 'xx.shl' as follows
$cat xx.shl
#!/bin/ksh
x1.shl
x2.shl
now I have to run xx.shl
daily. but I want to skip(not to execute) the x2.shl , if the date
is 25,26, 27 ...upto one day before of the last day.
for example
if the last date is 31, then
i don't want to execute the x2.shl
between 25,26,27,28,29,30.
if the last date is 28, then
i don't want to execute the x2.shl
between 25,26,27.
thanks in advance.
Vasu
$cat xx.shl
#!/bin/ksh
x1.shl
x2.shl
now I have to run xx.shl
daily. but I want to skip(not to execute) the x2.shl , if the date
is 25,26, 27 ...upto one day before of the last day.
for example
if the last date is 31, then
i don't want to execute the x2.shl
between 25,26,27,28,29,30.
if the last date is 28, then
i don't want to execute the x2.shl
between 25,26,27.
thanks in advance.
Vasu
keeping you ahead of the learning curve
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2002 07:29 AM
09-27-2002 07:29 AM
Re: shell script with date logic
Hi
In your script :-
last=`cal | sed '/^$/d' | tail -1 | head -1 | awk '{print $NF}'`
echo $last
this will gice the last day of the month.
So you can use an if statement
if [[ $last != 31]]
then
Paula
In your script :-
last=`cal | sed '/^$/d' | tail -1 | head -1 | awk '{print $NF}'`
echo $last
this will gice the last day of the month.
So you can use an if statement
if [[ $last != 31]]
then
Paula
If you can spell SysAdmin then you is one - anon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2002 07:42 AM
09-27-2002 07:42 AM
Solution
Hi Vasu"
You can leverage the 'cal' utility here:
#!/usr/bin/sh
TODAY=`date "+%d"`
LASTD=`cal|awk 'NF > 0 {LASTD=$NF};END{ print LASTD}'`
let LASTD=LASTD-1
if [ "$TODAY" -ge 25 -a "$TODAY" -le "$LASTD" ]
then
echo "skip"
else
echo "run!"
fi
exit 0
Regards!
...JRF...
You can leverage the 'cal' utility here:
#!/usr/bin/sh
TODAY=`date "+%d"`
LASTD=`cal|awk 'NF > 0 {LASTD=$NF};END{ print LASTD}'`
let LASTD=LASTD-1
if [ "$TODAY" -ge 25 -a "$TODAY" -le "$LASTD" ]
then
echo "skip"
else
echo "run!"
fi
exit 0
Regards!
...JRF...
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP