What is the difference between using crontab -e and /etc/crontab [duplicate]

Clash Royale CLAN TAG#URR8PPP
This question already has an answer here:
System Crontab or Root Crontab
2 answers
I wish to run stuff from startup and also trigger reboots using cron.
I was using sudo crontab -e and adding commands there. The commands work apart from the reboots. The reboots do not happen all the time. I wish to reboot at 4 am every morning. My added line is :
00 4 * * * root /sbin/shutdown -r now >> /var/log/daily-backup.log 2>&1
I now instead modified /etc/crontab instead for the reboots and it seems to work. Why is this? Shouldn't crontab -e work anyways because commands get run as root?
debian cron root reboot etc
 marked as duplicate by Jeff Schaller, jsbillings, Stephen Harris, Stephen Kitt
 StackExchange.ready(function() 
 if (StackExchange.options.isMobile) return;
 $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() 
 var $hover = $(this).addClass('hover-bound'),
 $msg = $hover.siblings('.dupe-hammer-message');
 $hover.hover(
 function() 
 $hover.showInfoMessage('', 
 messageElement: $msg.clone().show(),
 transient: false,
 position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
 dismissable: false,
 relativeToBody: true
 );
 ,
 function() 
 StackExchange.helpers.removeMessages();
 
 );
 );
 );
 Feb 18 at 15:12
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
System Crontab or Root Crontab
2 answers
I wish to run stuff from startup and also trigger reboots using cron.
I was using sudo crontab -e and adding commands there. The commands work apart from the reboots. The reboots do not happen all the time. I wish to reboot at 4 am every morning. My added line is :
00 4 * * * root /sbin/shutdown -r now >> /var/log/daily-backup.log 2>&1
I now instead modified /etc/crontab instead for the reboots and it seems to work. Why is this? Shouldn't crontab -e work anyways because commands get run as root?
debian cron root reboot etc
 marked as duplicate by Jeff Schaller, jsbillings, Stephen Harris, Stephen Kitt
 StackExchange.ready(function() 
 if (StackExchange.options.isMobile) return;
 $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() 
 var $hover = $(this).addClass('hover-bound'),
 $msg = $hover.siblings('.dupe-hammer-message');
 $hover.hover(
 function() 
 $hover.showInfoMessage('', 
 messageElement: $msg.clone().show(),
 transient: false,
 position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
 dismissable: false,
 relativeToBody: true
 );
 ,
 function() 
 StackExchange.helpers.removeMessages();
 
 );
 );
 );
 Feb 18 at 15:12
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
System Crontab or Root Crontab
2 answers
I wish to run stuff from startup and also trigger reboots using cron.
I was using sudo crontab -e and adding commands there. The commands work apart from the reboots. The reboots do not happen all the time. I wish to reboot at 4 am every morning. My added line is :
00 4 * * * root /sbin/shutdown -r now >> /var/log/daily-backup.log 2>&1
I now instead modified /etc/crontab instead for the reboots and it seems to work. Why is this? Shouldn't crontab -e work anyways because commands get run as root?
debian cron root reboot etc
This question already has an answer here:
System Crontab or Root Crontab
2 answers
I wish to run stuff from startup and also trigger reboots using cron.
I was using sudo crontab -e and adding commands there. The commands work apart from the reboots. The reboots do not happen all the time. I wish to reboot at 4 am every morning. My added line is :
00 4 * * * root /sbin/shutdown -r now >> /var/log/daily-backup.log 2>&1
I now instead modified /etc/crontab instead for the reboots and it seems to work. Why is this? Shouldn't crontab -e work anyways because commands get run as root?
This question already has an answer here:
System Crontab or Root Crontab
2 answers
debian cron root reboot etc
debian cron root reboot etc
asked Feb 18 at 14:39
Engineer999Engineer999
31319
31319
 marked as duplicate by Jeff Schaller, jsbillings, Stephen Harris, Stephen Kitt
 StackExchange.ready(function() 
 if (StackExchange.options.isMobile) return;
 $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() 
 var $hover = $(this).addClass('hover-bound'),
 $msg = $hover.siblings('.dupe-hammer-message');
 $hover.hover(
 function() 
 $hover.showInfoMessage('', 
 messageElement: $msg.clone().show(),
 transient: false,
 position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
 dismissable: false,
 relativeToBody: true
 );
 ,
 function() 
 StackExchange.helpers.removeMessages();
 
 );
 );
 );
 Feb 18 at 15:12
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
 marked as duplicate by Jeff Schaller, jsbillings, Stephen Harris, Stephen Kitt
 StackExchange.ready(function() 
 if (StackExchange.options.isMobile) return;
 $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() 
 var $hover = $(this).addClass('hover-bound'),
 $msg = $hover.siblings('.dupe-hammer-message');
 $hover.hover(
 function() 
 $hover.showInfoMessage('', 
 messageElement: $msg.clone().show(),
 transient: false,
 position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
 dismissable: false,
 relativeToBody: true
 );
 ,
 function() 
 StackExchange.helpers.removeMessages();
 
 );
 );
 );
 Feb 18 at 15:12
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
 1 Answer
 1
 
active
oldest
votes
If you do crontab -e then you're modifying the per user cron entry, typically in /var/spool/cron/crontabs/$USERNAME.
Because these are per-user, they don't have the requirement for a username.
So the entry would look something like
00 4 * * * /sbin/shutdown -r now >> /var/log/daily-backup.log 2>&1
In contrast, the /etc/crontab (and files in /etc/cron.d/) are sytem crontab entries, and so require a username.
You can see what cron is doing by looking at /var/log/syslog (on Debian; /var/log/cron on RedHat). If your job is being called then there should be a line in your daily-backup.log... potentially saying that it can't find the "root" command.
add a comment |
 1 Answer
 1
 
active
oldest
votes
 1 Answer
 1
 
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you do crontab -e then you're modifying the per user cron entry, typically in /var/spool/cron/crontabs/$USERNAME.
Because these are per-user, they don't have the requirement for a username.
So the entry would look something like
00 4 * * * /sbin/shutdown -r now >> /var/log/daily-backup.log 2>&1
In contrast, the /etc/crontab (and files in /etc/cron.d/) are sytem crontab entries, and so require a username.
You can see what cron is doing by looking at /var/log/syslog (on Debian; /var/log/cron on RedHat). If your job is being called then there should be a line in your daily-backup.log... potentially saying that it can't find the "root" command.
add a comment |
If you do crontab -e then you're modifying the per user cron entry, typically in /var/spool/cron/crontabs/$USERNAME.
Because these are per-user, they don't have the requirement for a username.
So the entry would look something like
00 4 * * * /sbin/shutdown -r now >> /var/log/daily-backup.log 2>&1
In contrast, the /etc/crontab (and files in /etc/cron.d/) are sytem crontab entries, and so require a username.
You can see what cron is doing by looking at /var/log/syslog (on Debian; /var/log/cron on RedHat). If your job is being called then there should be a line in your daily-backup.log... potentially saying that it can't find the "root" command.
add a comment |
If you do crontab -e then you're modifying the per user cron entry, typically in /var/spool/cron/crontabs/$USERNAME.
Because these are per-user, they don't have the requirement for a username.
So the entry would look something like
00 4 * * * /sbin/shutdown -r now >> /var/log/daily-backup.log 2>&1
In contrast, the /etc/crontab (and files in /etc/cron.d/) are sytem crontab entries, and so require a username.
You can see what cron is doing by looking at /var/log/syslog (on Debian; /var/log/cron on RedHat). If your job is being called then there should be a line in your daily-backup.log... potentially saying that it can't find the "root" command.
If you do crontab -e then you're modifying the per user cron entry, typically in /var/spool/cron/crontabs/$USERNAME.
Because these are per-user, they don't have the requirement for a username.
So the entry would look something like
00 4 * * * /sbin/shutdown -r now >> /var/log/daily-backup.log 2>&1
In contrast, the /etc/crontab (and files in /etc/cron.d/) are sytem crontab entries, and so require a username.
You can see what cron is doing by looking at /var/log/syslog (on Debian; /var/log/cron on RedHat). If your job is being called then there should be a line in your daily-backup.log... potentially saying that it can't find the "root" command.
answered Feb 18 at 14:45
Stephen HarrisStephen Harris
26.5k34780
26.5k34780
add a comment |
add a comment |