Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
02-23-2009, 04:56 AM
|
#1
|
|
Member
Registered: May 2007
Location: /dev/random
Distribution: CentOS, Fedora, RHEL, SuSE
Posts: 62
Rep:
|
cron at every 51st minute
Hi,
I want to run a cronjob at every 51st minute (not every hour 51 minute).
for example, if first run is at 1:51, then second run should be at 2:42 (every 51st minute).
Is specifying */51 in minute field do the trick? or there's something else I need to consider?
Please suggest.
|
|
|
|
02-23-2009, 05:05 AM
|
#2
|
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 42,711
|
No, that's not possible. Cron just periodically checks if any crontab entries match the current time. You'd need to write your own script to loop round or such like.
|
|
|
|
02-23-2009, 05:34 AM
|
#3
|
|
Moderator
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.4 OpenSuSE 12.2
Posts: 9,897
|
As suggested by acid_kewpie you have to do this by the script itself. For example you can write instructions at the end of the script to update the crontab:
Code:
#!/bin/bash
<your code here>
# -----------------------------------------------------------
# Update the crontab for the next job
# -----------------------------------------------------------
crontab < <(date -d "51 minutes" +"%M %H %d %m * $0")
Take in mind that the statement above overwrites the content of the crontab. If you have other entries in the actual crontab, they will be deleted. In this case you have to re-write them all from the script itself.
|
|
|
|
02-23-2009, 05:58 AM
|
#4
|
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 42,711
|
if it's only there to run once, i'd have thought an "at" command would be nicer...?
|
|
|
|
02-23-2009, 06:05 AM
|
#5
|
|
Senior Member
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Lenny/Squeeze/Wheezy/Sid
Posts: 3,801
|
I think the at command is suited better here.
Code:
#!/bin/bash
<your code here>
echo /path/to/your/script | at now+51 minutes
Doublecheck the syntax on at, else you will wait very long and see nothing happen.
jlinkels
=== Chris you were faster than I was!
|
|
|
|
02-23-2009, 06:06 AM
|
#6
|
|
Moderator
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.4 OpenSuSE 12.2
Posts: 9,897
|
I agree. This would overcome the problem of overwriting the whole crontab, too.
|
|
|
|
02-23-2009, 06:10 AM
|
#7
|
|
Member
Registered: May 2007
Location: /dev/random
Distribution: CentOS, Fedora, RHEL, SuSE
Posts: 62
Original Poster
Rep:
|
Thanks a lot!!
I'll have to take another look at requirement and make some more tweaks 
|
|
|
|
02-23-2009, 06:49 AM
|
#8
|
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 42,711
|
wrong thread. bum.
Last edited by acid_kewpie; 02-23-2009 at 06:52 AM.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 09:08 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|