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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
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: 43,417
|
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
|
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509
|
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: 43,417
|
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
|
LQ Guru
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
|
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
|
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509
|
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: 43,417
|
wrong thread. bum.
Last edited by acid_kewpie; 02-23-2009 at 06:52 AM.
|
|
|
All times are GMT -5. The time now is 12:18 AM.
|
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
|
|