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

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












0
















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?










share|improve this question













marked as duplicate by Jeff Schaller, jsbillings, Stephen Harris, Stephen Kitt debian
Users with the  debian badge can single-handedly close debian questions as duplicates and reopen them as needed.

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.






















    0
















    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?










    share|improve this question













    marked as duplicate by Jeff Schaller, jsbillings, Stephen Harris, Stephen Kitt debian
    Users with the  debian badge can single-handedly close debian questions as duplicates and reopen them as needed.

    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.




















      0












      0








      0









      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?










      share|improve this question















      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 18 at 14:39









      Engineer999Engineer999

      31319




      31319




      marked as duplicate by Jeff Schaller, jsbillings, Stephen Harris, Stephen Kitt debian
      Users with the  debian badge can single-handedly close debian questions as duplicates and reopen them as needed.

      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 debian
      Users with the  debian badge can single-handedly close debian questions as duplicates and reopen them as needed.

      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.






















          1 Answer
          1






          active

          oldest

          votes


















          2














          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.






          share|improve this answer





























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            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.






            share|improve this answer



























              2














              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.






              share|improve this answer

























                2












                2








                2







                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.






                share|improve this answer













                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.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 18 at 14:45









                Stephen HarrisStephen Harris

                26.5k34780




                26.5k34780












                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?