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.

Is it just for controlling the permissions of the script being called or does it also effect when or if the script runs? I assume if I setup a cron for a non-root user it should always run, even if I haven't logged in as that user since reboot, right?

share|improve this question
add comment

3 Answers

up vote 7 down vote accepted

Remember that Unix was originally designed as a multi-user system, where multiple people were using the same physical computer. (Unlike today, where most Unix systems are used by only one person, and multiple user accounts are just to limit vulnerabilities.)

So the original reason for per-user crontabs was so that each person could schedule jobs they wanted run periodically (without giving them permissions to edit the system crontab, and thus interfere with other people's jobs). But now, it's primarily just to control the permissions of the jobs being run.

So yes, once a crontab is saved, the jobs will run whether or not that user is logged in (or has ever logged in). The main cron daemon runs the per-user crontabs as well as the system crontab.

share|improve this answer
    
Good point, if they were both editing the same system file that would be a headache. –  ioSamurai May 10 '12 at 20:18
add comment

Basically, it allows an unprivileged user to have cron jobs. And yes, you will want cron jobs if you want regular things done. And yes, it will persist across reboots.

at/batch provides similar facilities if you don't want "periodically forever" semantics.

share|improve this answer
add comment

Also note that jobs in non-root crontabs will be executed as that user. Whereas in /etc/crontab and the /etc/cron.d, /etc/cron.daily etc. directories the system admin can select the user account the job will run as because it has an additional entry.

From man 5 crontab:

   The format of a cron command is very much the V7 standard,  with
   a  number  of  upward-compatible extensions.  Each line has five
   time and date fields, followed by a user name  if  this  is  the
   system  crontab  file, followed by a command.
share|improve this answer
add comment

Your Answer

 
discard

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.