Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
I find your comments quite confusing, are you narrating your attempts? – zenzelezz Nov 9 '12 at 14:52
It helps considerably if you have a specific question in mind and you've already put some effort into solving it. You asked three cron-related questions right in a row, as if you're posting every time you run into a problem. Try to get things set up, and then if you have a specific issue and you can't find anything in the documentation, ask one specific question about it – Michael Mrozek Nov 9 '12 at 18:09

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. – Jodie C Nov 9 '12 at 14:02

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