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?
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.
crontab -eto read about the user crontab file andcat /etc/crontabto 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/etc/crontabis for system-wide, then where is the crontab file for a user? – Tim Apr 21 '15 at 19:42man crontabon Ubuntu the user crontab file is located in/var/spool/cron/crontabs. But be carefull, the manual also say that those files are not intended for direct editing. You should usecrontab -efrom the user context orcrontab -e -u usernamefrom the root user to edit the user crontab. – Lambert Apr 21 '15 at 19:49~/.crontabbycrontab ~/.crontab. Is it a good suggestion? – Tim Apr 21 '15 at 19:53~/.crontabis not a special file and not your actual crontab. It's merely a local file you may keep for backup purposes, and you can name it whatever you want, say~/crontab.txt. You can save it to your crontab usingcrontab ~/crontab.txtand generate it withcrontab -l > ~/crontab.txt– MestreLion May 10 '22 at 15:04