- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how to sort crontab in unix
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
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
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
тАО08-23-2004 08:27 PM
тАО08-23-2004 08:27 PM
how to sort crontab in unix
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2004 08:35 PM
тАО08-23-2004 08:35 PM
Re: how to sort crontab in unix
The fields in format x,x,x
Will give a problem but
crontab -l|sort -k 1,1 -k 2,2 -k 3,3
Works
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2004 08:37 PM
тАО08-23-2004 08:37 PM
Re: how to sort crontab in unix
CRON ENTRIES
minutes hours day Month day_off_week
Hope this helps,
Robert-Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2004 08:40 PM
тАО08-23-2004 08:40 PM
Re: how to sort crontab in unix
this should work with
crontab -l | sort -k1 -k2 -k3
Regards
Franky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2004 08:59 PM
тАО08-23-2004 08:59 PM
Re: how to sort crontab in unix
Try as like,
crontab -l | sort -nbk 1,3
It will sort 1 to 3 fields one by one.
-nb are used for optional field separation between the fields.
Regards
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2004 09:55 PM
тАО08-23-2004 09:55 PM
Re: how to sort crontab in unix
this is how my end of crontab looks like:
#*******************************************************************************
# min|hour |day |month|day |script
# | |of mo| |of wk|
#----|-----|-----|-----|-----|--------------------------------------------------
#*******************************************************************************
#*******************************************************************************
# END OF TABLE day0->Sunday day6->Saturday
#*******************************************************************************
one easy way to see it sorted is using SAM->Process Management->Scheduled Cron Jobs->View->sort
regards
Yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2004 11:39 PM
тАО08-23-2004 11:39 PM
Re: how to sort crontab in unix
I wanted to sort first w.r.t minutes and then w.r.t seconds, and the following got me the desired result.
crontab -l | grep -v ^# | sort -nb -k 2,1,3
...
But i would like to know.. why we are using
-k 2,2 1,1
in this case: crontab -l|sort -k 2,2 -k 1,1 -k 3,3.
Also, i am looking at extracting crontabs for a given timeframe say from 7 am to 8 am.
What i intend to do is to read the sorted crontab into a file and then extract cron-entries from 7am to 8am.
But is there a better method of doing the same?
Do let me know.
Thanks to one and all
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2004 11:51 PM
тАО08-23-2004 11:51 PM
Re: how to sort crontab in unix
IF you are going to sort with multiple fields one by one then we have to use multiple keys else,
crontab -l | grep -v ^# | sort -nb -k 2,1,3
it will not give the effect.
IF you are trying to sort as non-order then ( 2 , 1 , 3) then you have to use multiple keys. Else you can as like as -k 1,3 ( to sort from 1 to 3)
In your case it will sort based on 2nd field then 1st then 3rd one.
You can also use as,
crontab -l | grep -v ^# | sort -nb -k 2,2 1,1 3,3
or
crontab -l | grep -v ^# | sort -nb -k 2 -k 1 -k 3
-k --> startpos , end pos
You can give or need not.
To know more about the difference refer the sort man page for -k options. It will give some more effective features / usage on keys
Regarding extraction on time limit, it is good to extract the timelimits on sorted cornjobs with grep command.
It will give the way to do.
Regards
+Muthu+
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-24-2004 12:31 AM
тАО08-24-2004 12:31 AM
Re: how to sort crontab in unix
I am sorting crontab and then grep cron for the timeframe.
Regards,
Surekha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-24-2004 01:10 AM
тАО08-24-2004 01:10 AM
Re: how to sort crontab in unix
don't forget to assign points ...
Regards
Franky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-24-2004 02:37 PM
тАО08-24-2004 02:37 PM
Re: how to sort crontab in unix
Any of the following may be used to sort the crontab:
crontab -l | grep -v ^# | sort -nb -k 2,1,3
or
crontab -l | grep -v ^# | sort -nb -k 2,2 1,1 3,3
or
crontab -l | grep -v ^# | sort -nb -k 2 -k 1 -k 3