- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Cron every 2 mins
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
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
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
тАО04-03-2007 03:39 PM
тАО04-03-2007 03:39 PM
Sorry to ask a basic question. How can we run cron every 2 mins? Should list such 2,4,6,8,etc * * * *? Is there any better way?
Pls help.
Thanks and Best regards,
Negara
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2007 04:00 PM
тАО04-03-2007 04:00 PM
Solution- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2007 04:01 PM
тАО04-03-2007 04:01 PM
Re: Cron every 2 mins
Another way to do it would be via 'at'. At the end of your script you do an 'at scriptname now + 2 minutes' 'man at' for more information.
# cat script
#!/usr/bin/sh
do stuff
do more stuff
do even more stuff
at /dir/script now +2 minutes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2007 05:29 PM
тАО04-03-2007 05:29 PM
Re: Cron every 2 mins
the most easy and dull way to do it is:
#***************************************
00 * * * * /home/yogeeraj/myscript.sh
02 * * * * /home/yogeeraj/myscript.sh
04 * * * * /home/yogeeraj/myscript.sh
06 * * * * /home/yogeeraj/myscript.sh
..
50 * * * * /home/yogeeraj/myscript.sh
52 * * * * /home/yogeeraj/myscript.sh
54 * * * * /home/yogeeraj/myscript.sh
56 * * * * /home/yogeeraj/myscript.sh
58 * * * * /home/yogeeraj/myscript.sh
#***************************************
# min|hour |day |month|day |script
# | |of mo| |of wk|
#----|-----|-----|-----|-----|-----------
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2007 07:31 PM
тАО04-03-2007 07:31 PM
Re: Cron every 2 mins
You can run the script every minute, but to put into the script the following:
typeset -i N=0
N=$(date +%m)%2
if [ $N -ne 0 ]; then
exit
fi
#Your script etc
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2007 08:22 PM
тАО04-03-2007 08:22 PM
Re: Cron every 2 mins
There is a mistake in date format.
typeset -i N=0
N=$(date +%M)%2
if [ $N -ne 0 ]; then
exit
fi
According to the condition the script will exit every odd minute and will work every even minute.
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2007 11:00 PM
тАО04-03-2007 11:00 PM
Re: Cron every 2 mins
you have to setup your cronjob every minute, but can prepend a one-liner to skip the add minute:
* * * * * [ $(date '+\%M 2\%\%p' | dc) -eq 1 ] || /path/2your/your-cron-script
The above construct will NOT have an exit status != 0 for skipped minutes.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2007 02:57 PM
тАО04-04-2007 02:57 PM
Re: Cron every 2 mins
It looks fine to me now. Thanks alot for all your help.
Best Regards,
Negara
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-04-2007 04:06 PM
тАО04-04-2007 04:06 PM