- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- scripting help.
Categories
Company
Local Language
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
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
Community
Resources
Forums
Blogs
- 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
06-01-2006 03:17 AM
06-01-2006 03:17 AM
I am trying to create a script that checks the run time of a job from a file then works out whether another script should run. ie
script where date and times are:
LOG
monday 2200 - 0700
tuesday 0800 - 1700
wednesday 0800 - 1700
etc etc
BACKUP
monday 0800 - 0700
tuesday 0900 - 1700
wednesday 0800 - 1700
etc etc
so
i try running awk to search for BACKUP then check the date and get the time as a string to be tested against the current time.
but
i just cannot work it out,
please help.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2006 03:36 AM
06-01-2006 03:36 AM
Re: scripting help.
todaysday=$(date +%A | tr -s [:upper:] [:lower:])
todaystime=$(date +%H%M)
awk '/BACKUP/,/ZZZ/' logfile | grep $todaysdate | head -1 | read logday starttime junk1 endtime
if [[ $todaystime -ge $starttime ]]
then
if [[ $todaystime -le $endtime ]]
then
echo Run script
fi
fi
Hope this is what your requirement is.
Please clarify if not.
Best luck.
Ninad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2006 03:38 AM
06-01-2006 03:38 AM
Solutiontodaysday=$(date +%A | tr -s [:upper:] [:lower:])
todaystime=$(date +%H%M)
awk '/BACKUP/,/ZZZ/' logfile | grep $todaysdate | head -1 | read logday starttime junk1 endtime
if [[ "$todaysday" = "$logday" ]]
then
if [[ $todaystime -ge $starttime ]]
then
if [[ $todaystime -le $endtime ]]
then
echo Run script
fi
fi
fi
Regards,
Ninad
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2006 03:58 AM
06-01-2006 03:58 AM
Re: scripting help.
You can use this to extract the line corresponding to the current day (name) in the stanza beginning with "BACKUP":
# perl -ne 'BEGIN{$d=substr(localtime,0,3)};$i++ if m/BACKUP/;print if $i && m/$d/i' filename
...If your file contained a line for today (a Thursday) in the "BACKUP" stanza, it would print that line. You can capture that output in a shell variable and parse the fields you want however you want.
Regards!
...JRF...
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2006 08:10 PM
06-01-2006 08:10 PM
Re: scripting help.
cheers!
Lawrenz0