Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have been doing some research on scheduling tasks and what not. I came across the crontab command function.

Is crontab a file that is created or is it a command?

If it is a file, then how many can one user have? Are they user-specific or system-specific (for instance, if I create a task using crontab, will the task execute if another user logs in to the system?)

If it is a command, where does it store the info for executing tasks?

share|improve this question
You should wait with accepting an answer for a day or so. Maybe others come by that have an even better answer than mine. Yes, accepting an answer is important for this website to work optimally, but most important is that you get the best answer possible. Many people won't look at a question that is marked as answered and therefore won't leave their insight. –  jippie Nov 5 '12 at 21:11
ah i see what you're saying, i just thought i'd mark your answer for the purpose of others but you raise an important point. NOTED! –  Craig Wayne Nov 6 '12 at 0:07
add comment

1 Answer

The command crontab -e will create a file, but you don't need to know about that and should never edit it by hand.

man crontab shows you the various options, most important ones being:

  • crontab -e edit
  • crontab -l list

Notice that your environment as a cron job is quite different from the one you are used to in an interactive shell. Easiest to inspect this is to set a cron job as follows:

* * * * * set > /tmp/environment.log

# | | |  \day of week    0-7 (0 or 7 is Sun, or use names)
# | |  \--month          1-12 (or names, see below)
# |  \----day of month   1-31
#  \------hour           0-23
#\--------minute         0-59

For the syntax of the crontab itself check man 5 crontab.

Then wait for a minute and remove the cronjob again, because otherwise this nonsense job will run every minute.

Then check the difference between the interactive shell (just type set) and the cronjob (just type cat /tmp/environment). Especially PATH and SHELL may surprise you.

share|improve this answer
thanks @jippie! Are they system tasks that run regardless of what user is logged in or user specific? –  Craig Wayne Nov 5 '12 at 21:02
You don't need to be logged on, cronjobs will always run as configured (the * * * * * part). They will run however by default as the user who created the crontab. –  jippie Nov 5 '12 at 21:04
Answering my own Question: Extract from wikipedia: "...Users can have their own individual crontab files and often there is a system wide crontab file (usually in /etc or a subdirectory of /etc) which only system administrators can edit..." –  Craig Wayne Nov 5 '12 at 21:04
thanks @jippie :) –  Craig Wayne Nov 5 '12 at 21:05
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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