Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to run cron every minute OR hour xclock.

It's not that simple as I guessed:(

I'll wait for your answer, sir. Maybe It'll be too late, before the right answer as 1 2 3...

share|improve this question

closed as not a real question by Chris Down, Renan, manatwork, rahmu, jw013 Nov 9 '12 at 17:20

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
"/tmp/crontab.XXXXtxJdHs" 1L, 19C –  Xsi Nov 9 '12 at 13:55
    
crontab -e */1 * * * xclock –  Xsi Nov 9 '12 at 13:56
    
o you want to retry the same edit? n crontab: edits left in /tmp/crontab.XXXXtxJdHs –  Xsi Nov 9 '12 at 13:56
    
Wait a minute for my xclock –  Xsi Nov 9 '12 at 13:57
1  
I find your comments quite confusing, are you narrating your attempts? –  zenzelezz Nov 9 '12 at 14:52

2 Answers 2

Delh's answer is partly wrong: */1 * * * * won't run a command hourly.

*/1 * * * * YourCommandHere would run the command every minute.

To start a job every hour:

0 * * * * YourCommandHere on Minute "0"

15 * * * * YourCommandHere on Minute 15, just as an example

*/2 * * * * YourCommandHere Runs the command every two minutes

0 */3 * * * YourCommandHere Runs the command every 3 Hours, when the Minute is 0

And to add to that: his questions seems like it could be merged up with crontab -e , then 0 * * * * = every hour; then xclock

share|improve this answer
    
My fault, edited my answer. Guess I shouldn't be posting in a sleep deprived state! +1 –  delh Nov 9 '12 at 21:09
    
Hehe, i know that state very well... :) –  Bonsi Scott Nov 9 '12 at 21:19

To add or remove a cronjob use the following command:

crontab -e

if this comes up with your least favourite editor (nano for me) you can use something like this to change that:

export EDITOR=vim|vi|nano|ed

Each line represents a scheduled job, unless it is commented with a #.

The six fields have the following values:

m h dom mon dow command

To define the time you can provide concrete values for minute (m), hour (h), day of month (dom), month (mon), and day of week (dow) or use '*' in these fields (for 'any').

To execute a command every minute add a command like this:

/1 * * * * YourCommandHere

To execute a command every two minutes it would look like this:

/2 * * * * YourCommandHere

To run a job every hour:

0 * * * *  YourCommandHere

To run a job at 5 a.m every week with:

0 5 * * 1  YourCommandHere

To see what jobs are scheduled for your account use the command:

crontab -l

A log entry should appear in /var/log/syslog when a job is run.

share|improve this answer
    
Your “every hour” code misses a space. –  manatwork Nov 9 '12 at 13:39
    
from man 5 crontab: if you want to say 'every two hours', just use */2'. –  delh Nov 9 '12 at 13:42
    
Ok, then your “every hour” code misses an asterisk. –  manatwork Nov 9 '12 at 13:46
    
I tested it and you are so right! Thanks. The */n thing is always a bit confusing as to count it as one or two positions. –  delh Nov 9 '12 at 13:54
    
@delh - The slash syntax is not portable to many Unixes. –  JodieC Nov 9 '12 at 14:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.