/sbin/shutdown -h now; not working in crontab

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











up vote
0
down vote

favorite












I've made a script to update and upgrade at 12.15 every Friday and after both of these jobs have been completed shut down.



The updates work fine, however it does not shut down afterwards. I've tried to look it up and used the suggestions that I could find so far, but it doesn't seem to do anything, this is my script:



#crontab
#minute(s) hour(s) day(s) month(s) weekday(s) command(s)

15 12 * * 5 (/usr/bin/apt-get -y update; /usr/bin/apt-get -y upgrade; /usr/bin/touch /home/pi/cron_output.log;) 2>&1 >> /home/pi/cron_output.log; /sbin/shutdown -h now;


The /sbin/shutdown -h now; part appears to not be working and I have no clue on how to fix it



I'm running this on a raspberry pi.










share|improve this question







New contributor




Joeri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • What is the location of this crontab entry? If in /etc/crontab, you would need to specify a user (e.g. root) before the command. If it is in /var/spool/cron/crontabs/pi (the location if you edited it as the pi user via crontab -e), then the pi user might not have sufficient access to run /sbin/shutdown. On my Raspberry Pi, the pi user is prompted for credentials when running /sbin/shutdown.
    – cherdt
    yesterday










  • The crontab is stored in /var/spool/cron/crontabs/pi it might be the case that pi does not have sufficient privileges. So does that mean that I should create a new crontab with sudo crontab -e -u root?
    – Joeri
    yesterday











  • I tried it an that seems to be the problem, thank you
    – Joeri
    yesterday










  • Glad it worked! It might be easy to forget where the entry is if it's in root's crontab, although that certainly works. I would probably put it in the existing /etc/crontab or create a new file in /etc/cron.d. The only difference in format between those and a specific user's crontab is that the username needs to be specified, e.g. 15 12 * * 5 root command
    – cherdt
    yesterday














up vote
0
down vote

favorite












I've made a script to update and upgrade at 12.15 every Friday and after both of these jobs have been completed shut down.



The updates work fine, however it does not shut down afterwards. I've tried to look it up and used the suggestions that I could find so far, but it doesn't seem to do anything, this is my script:



#crontab
#minute(s) hour(s) day(s) month(s) weekday(s) command(s)

15 12 * * 5 (/usr/bin/apt-get -y update; /usr/bin/apt-get -y upgrade; /usr/bin/touch /home/pi/cron_output.log;) 2>&1 >> /home/pi/cron_output.log; /sbin/shutdown -h now;


The /sbin/shutdown -h now; part appears to not be working and I have no clue on how to fix it



I'm running this on a raspberry pi.










share|improve this question







New contributor




Joeri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • What is the location of this crontab entry? If in /etc/crontab, you would need to specify a user (e.g. root) before the command. If it is in /var/spool/cron/crontabs/pi (the location if you edited it as the pi user via crontab -e), then the pi user might not have sufficient access to run /sbin/shutdown. On my Raspberry Pi, the pi user is prompted for credentials when running /sbin/shutdown.
    – cherdt
    yesterday










  • The crontab is stored in /var/spool/cron/crontabs/pi it might be the case that pi does not have sufficient privileges. So does that mean that I should create a new crontab with sudo crontab -e -u root?
    – Joeri
    yesterday











  • I tried it an that seems to be the problem, thank you
    – Joeri
    yesterday










  • Glad it worked! It might be easy to forget where the entry is if it's in root's crontab, although that certainly works. I would probably put it in the existing /etc/crontab or create a new file in /etc/cron.d. The only difference in format between those and a specific user's crontab is that the username needs to be specified, e.g. 15 12 * * 5 root command
    – cherdt
    yesterday












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I've made a script to update and upgrade at 12.15 every Friday and after both of these jobs have been completed shut down.



The updates work fine, however it does not shut down afterwards. I've tried to look it up and used the suggestions that I could find so far, but it doesn't seem to do anything, this is my script:



#crontab
#minute(s) hour(s) day(s) month(s) weekday(s) command(s)

15 12 * * 5 (/usr/bin/apt-get -y update; /usr/bin/apt-get -y upgrade; /usr/bin/touch /home/pi/cron_output.log;) 2>&1 >> /home/pi/cron_output.log; /sbin/shutdown -h now;


The /sbin/shutdown -h now; part appears to not be working and I have no clue on how to fix it



I'm running this on a raspberry pi.










share|improve this question







New contributor




Joeri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I've made a script to update and upgrade at 12.15 every Friday and after both of these jobs have been completed shut down.



The updates work fine, however it does not shut down afterwards. I've tried to look it up and used the suggestions that I could find so far, but it doesn't seem to do anything, this is my script:



#crontab
#minute(s) hour(s) day(s) month(s) weekday(s) command(s)

15 12 * * 5 (/usr/bin/apt-get -y update; /usr/bin/apt-get -y upgrade; /usr/bin/touch /home/pi/cron_output.log;) 2>&1 >> /home/pi/cron_output.log; /sbin/shutdown -h now;


The /sbin/shutdown -h now; part appears to not be working and I have no clue on how to fix it



I'm running this on a raspberry pi.







cron shutdown






share|improve this question







New contributor




Joeri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Joeri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Joeri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









Joeri

11




11




New contributor




Joeri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Joeri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Joeri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • What is the location of this crontab entry? If in /etc/crontab, you would need to specify a user (e.g. root) before the command. If it is in /var/spool/cron/crontabs/pi (the location if you edited it as the pi user via crontab -e), then the pi user might not have sufficient access to run /sbin/shutdown. On my Raspberry Pi, the pi user is prompted for credentials when running /sbin/shutdown.
    – cherdt
    yesterday










  • The crontab is stored in /var/spool/cron/crontabs/pi it might be the case that pi does not have sufficient privileges. So does that mean that I should create a new crontab with sudo crontab -e -u root?
    – Joeri
    yesterday











  • I tried it an that seems to be the problem, thank you
    – Joeri
    yesterday










  • Glad it worked! It might be easy to forget where the entry is if it's in root's crontab, although that certainly works. I would probably put it in the existing /etc/crontab or create a new file in /etc/cron.d. The only difference in format between those and a specific user's crontab is that the username needs to be specified, e.g. 15 12 * * 5 root command
    – cherdt
    yesterday
















  • What is the location of this crontab entry? If in /etc/crontab, you would need to specify a user (e.g. root) before the command. If it is in /var/spool/cron/crontabs/pi (the location if you edited it as the pi user via crontab -e), then the pi user might not have sufficient access to run /sbin/shutdown. On my Raspberry Pi, the pi user is prompted for credentials when running /sbin/shutdown.
    – cherdt
    yesterday










  • The crontab is stored in /var/spool/cron/crontabs/pi it might be the case that pi does not have sufficient privileges. So does that mean that I should create a new crontab with sudo crontab -e -u root?
    – Joeri
    yesterday











  • I tried it an that seems to be the problem, thank you
    – Joeri
    yesterday










  • Glad it worked! It might be easy to forget where the entry is if it's in root's crontab, although that certainly works. I would probably put it in the existing /etc/crontab or create a new file in /etc/cron.d. The only difference in format between those and a specific user's crontab is that the username needs to be specified, e.g. 15 12 * * 5 root command
    – cherdt
    yesterday















What is the location of this crontab entry? If in /etc/crontab, you would need to specify a user (e.g. root) before the command. If it is in /var/spool/cron/crontabs/pi (the location if you edited it as the pi user via crontab -e), then the pi user might not have sufficient access to run /sbin/shutdown. On my Raspberry Pi, the pi user is prompted for credentials when running /sbin/shutdown.
– cherdt
yesterday




What is the location of this crontab entry? If in /etc/crontab, you would need to specify a user (e.g. root) before the command. If it is in /var/spool/cron/crontabs/pi (the location if you edited it as the pi user via crontab -e), then the pi user might not have sufficient access to run /sbin/shutdown. On my Raspberry Pi, the pi user is prompted for credentials when running /sbin/shutdown.
– cherdt
yesterday












The crontab is stored in /var/spool/cron/crontabs/pi it might be the case that pi does not have sufficient privileges. So does that mean that I should create a new crontab with sudo crontab -e -u root?
– Joeri
yesterday





The crontab is stored in /var/spool/cron/crontabs/pi it might be the case that pi does not have sufficient privileges. So does that mean that I should create a new crontab with sudo crontab -e -u root?
– Joeri
yesterday













I tried it an that seems to be the problem, thank you
– Joeri
yesterday




I tried it an that seems to be the problem, thank you
– Joeri
yesterday












Glad it worked! It might be easy to forget where the entry is if it's in root's crontab, although that certainly works. I would probably put it in the existing /etc/crontab or create a new file in /etc/cron.d. The only difference in format between those and a specific user's crontab is that the username needs to be specified, e.g. 15 12 * * 5 root command
– cherdt
yesterday




Glad it worked! It might be easy to forget where the entry is if it's in root's crontab, although that certainly works. I would probably put it in the existing /etc/crontab or create a new file in /etc/cron.d. The only difference in format between those and a specific user's crontab is that the username needs to be specified, e.g. 15 12 * * 5 root command
– cherdt
yesterday










1 Answer
1






active

oldest

votes

















up vote
0
down vote













ANSWER GIVEN BY cherdt, I ONLY POST BECAUSE IT'S A COMMENT AND I WANT TO CLOSE THIS QUESTION



I messed up the privileges, it had to be run as root.
Either use /usr/bin/sudo before commands or create crontab as root






share|improve this answer








New contributor




Joeri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    Joeri is a new contributor. Be nice, and check out our Code of Conduct.









     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f473823%2fsbin-shutdown-h-now-not-working-in-crontab%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    ANSWER GIVEN BY cherdt, I ONLY POST BECAUSE IT'S A COMMENT AND I WANT TO CLOSE THIS QUESTION



    I messed up the privileges, it had to be run as root.
    Either use /usr/bin/sudo before commands or create crontab as root






    share|improve this answer








    New contributor




    Joeri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      0
      down vote













      ANSWER GIVEN BY cherdt, I ONLY POST BECAUSE IT'S A COMMENT AND I WANT TO CLOSE THIS QUESTION



      I messed up the privileges, it had to be run as root.
      Either use /usr/bin/sudo before commands or create crontab as root






      share|improve this answer








      New contributor




      Joeri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.



















        up vote
        0
        down vote










        up vote
        0
        down vote









        ANSWER GIVEN BY cherdt, I ONLY POST BECAUSE IT'S A COMMENT AND I WANT TO CLOSE THIS QUESTION



        I messed up the privileges, it had to be run as root.
        Either use /usr/bin/sudo before commands or create crontab as root






        share|improve this answer








        New contributor




        Joeri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        ANSWER GIVEN BY cherdt, I ONLY POST BECAUSE IT'S A COMMENT AND I WANT TO CLOSE THIS QUESTION



        I messed up the privileges, it had to be run as root.
        Either use /usr/bin/sudo before commands or create crontab as root







        share|improve this answer








        New contributor




        Joeri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        Joeri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered yesterday









        Joeri

        11




        11




        New contributor




        Joeri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        Joeri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        Joeri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.




















            Joeri is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            Joeri is a new contributor. Be nice, and check out our Code of Conduct.












            Joeri is a new contributor. Be nice, and check out our Code of Conduct.











            Joeri is a new contributor. Be nice, and check out our Code of Conduct.













             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f473823%2fsbin-shutdown-h-now-not-working-in-crontab%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

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

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay