/sbin/shutdown -h now; not working in crontab
Clash 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.
cron shutdown
New contributor
add a comment |Â
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.
cron shutdown
New contributor
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 thepi
user viacrontab -e
), then thepi
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 thatpi
does not have sufficient privileges. So does that mean that I should create a new crontab withsudo 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
add a comment |Â
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.
cron shutdown
New contributor
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
cron shutdown
New contributor
New contributor
New contributor
asked yesterday
Joeri
11
11
New contributor
New contributor
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 thepi
user viacrontab -e
), then thepi
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 thatpi
does not have sufficient privileges. So does that mean that I should create a new crontab withsudo 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
add a comment |Â
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 thepi
user viacrontab -e
), then thepi
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 thatpi
does not have sufficient privileges. So does that mean that I should create a new crontab withsudo 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
add a comment |Â
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
New contributor
add a comment |Â
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
New contributor
add a comment |Â
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
New contributor
add a comment |Â
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
New contributor
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
New contributor
New contributor
answered yesterday
Joeri
11
11
New contributor
New contributor
add a comment |Â
add a comment |Â
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.
Joeri is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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 thepi
user viacrontab -e
), then thepi
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 thatpi
does not have sufficient privileges. So does that mean that I should create a new crontab withsudo 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