12

I add some job in crontab file on a server.

  • When I log out and the server is still on, will the job still run?

  • Does it matter if I create a screen or tmux session and run some shell in it and detach it before log out?

22

cron is a process which deals with scheduled tasks whether you are logged in or not. It is not necessary to have a screen or tmux session running since the cron daemon will execute the scheduled tasks in separate shells.

See man cron and man crontab for details.

  • when I log out, which user will run and own the job scheduled in crontab? If it is not me, can that cause some potential problem? – Tim Apr 21 '15 at 13:08
  • 1
    That depends on which crontab you edited. If you edit the crontab of a user the entries are executed as that user. If you edited the /etc/crontab file the user is often specified between the interval and the command like: "17 * * * * root cd / && run-parts --report /etc/cron.hourly". Besides it does also depend on the platform you are using. Ubuntu uses a different cron than for instance Solaris – Lambert Apr 21 '15 at 13:14
  • I use ubuntu. What is "the crontab of a user"? In "the crontab of a user", can I also specify which user will run a scheduled job? – Tim Apr 21 '15 at 13:26
  • Ubuntu cron has some explanation text in the crontab files. As a user perform crontab -e to read about the user crontab file and cat /etc/crontab to read about the server-wide crontab file. From a user crontab file you can not run commands using a different user although it is possible to use sudo if passwordless commands are specified – Lambert Apr 21 '15 at 13:33
  • Thanks. /etc/crontab is for system-wide, then where is the crontab file for a user? – Tim Apr 21 '15 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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