LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-04-2014, 01:17 AM   #1
desiretolearn
LQ Newbie
 
Registered: Jan 2014
Posts: 25

Rep: Reputation: Disabled
cron code


how to write a cron that runs for every minute

Last edited by desiretolearn; 02-04-2014 at 04:02 AM.
 
Old 02-04-2014, 01:44 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
1-10 0 * * *
Would run each minute at the start of the day and only 10 times that day.

Also I doubt that this is what you really want. Maybe elaborate a bit more on what you try to achieve.
 
1 members found this post helpful.
Old 02-04-2014, 01:55 AM   #3
desiretolearn
LQ Newbie
 
Registered: Jan 2014
Posts: 25

Original Poster
Rep: Reputation: Disabled
* *


eloboration--> a cron to execute my script only every minutein a day for every minute

Last edited by desiretolearn; 02-04-2014 at 04:02 AM.
 
Old 02-04-2014, 01:56 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
As zhjim said. Or write a loop inside your script and run it only once:
Code:
#!/bin/bash
for i in {1..10}
do
  # your code here
  sleep 60
done
This will repeat your code for 10 times every 60 seconds (or more depending on the time of execution of your code).
 
1 members found this post helpful.
Old 02-04-2014, 01:57 AM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Quote:
Originally Posted by desiretolearn View Post
what woould happen if i give 1-10 * * * *


eloboration--> a cron to execute my script only 10 times in a day for every minute
It will run at minutes 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 of every hour, therefore 240 times per day.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cron.hourly : return code 127 barathan Linux - Newbie 8 01-08-2013 12:05 AM
run-parts: /etc/cron.daily/man-db exited with return code 2 cccc Debian 1 03-03-2007 05:46 AM
how to make a simple code for just restarting Apache via a Cron job hsa Programming 1 08-22-2005 04:15 AM
Freshclam exit code & cron timmywo Linux - General 0 05-21-2005 10:55 AM
Setting cron by php code? VertiHost Programming 1 10-15-2003 06:41 PM


All times are GMT -5. The time now is 09:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration