Jump to content

shutdown and access permitions


sud_crow
 Share

Recommended Posts

Hi again. :roll:

 

This time im going to ask about shutdown

 

Its pretty simple, i dont want to make something wrong and i dont think the question will bother someone...

 

I normally use shutdown -h +xxx being xxx a number of minutes, i use this to shutdown the PC when i go to sleep and let it downloading or compiling something and i want it to go down after (i assume) it finished the task.

 

The problem is that i have to be root to use the shutdown command, and i dont understand why. According to this:

 

-rwxr-xr-x    1 root     root        16344 ene 19 19:44 shutdown*

 

as you can see i have the execute permition set to every user, but it doesnt work it posts this:

the file is located in : /sbin/shutdown

 

bash: shutdown: command not found  

 

well, thats it. :oops:

Link to comment
Share on other sites

use 'halt' instead which is in the user's $PATH (notice that you can still run shutdown if you provide the full path to its executable. The error you are getting means that shutdown is not in user's $PATH)

 

If you want to do a task and then halt the system, instead of calculate the number of minutes that left to the end of the task, you can run the task and then tell the system to stop (/usr/bin/halt)

 

~$ my_task || { echo "the task failed at $(date)" | mail -s "task failed" $USER; }; halt

 

Which is a dirty way to do:

  • Run your task, whatever it is.

 

[*]if the task fails (return status != 0) for whatever reason mail the user telling that the task has failed at a given time (this can be work out a bit more to mail the user the reason of the failure).

 

[*]No matter if the task has succeed or not, tell the system to shutdown after my_task exits

Link to comment
Share on other sites

Hi,

 

well i didnt post before becouse i wanted to try out that...

 

but what i usually leave downloading stuff... and i cant dont think i can set that of 'when finishes' mainly becouse i download with the mozilla downloader, with KGet, and others, so, i could do it for urpmi or even wget... but not for the above.

 

also, i can run halt as a normal user, but cant i set it up like shutdown for a determined time/minutes...??

 

----------

 

Lei que sos de España, te molesta si te mando un privado para hablar en castellano??

Link to comment
Share on other sites

but what i usually leave downloading stuff... and i cant dont think i can set that of 'when finishes' mainly becouse i download with the mozilla downloader, with KGet, and others, so, i could do it for urpmi or even wget... but not for the above.

True. But if you want to do automatic or almost automatic tasks you'll have to get used to those apps that are enough powerfull for being able to be used in automatic mode (wget, ftp, lftp, rpm, lynx,... )

 

also, i can run halt as a normal user, but cant i set it up like shutdown for a determined time/minutes...??

easy, run:

~$ {sleep -m MINUTES && halt} &

or schedule the task with /usr/bin/at or /usr/bin/crontab

 

Lei que sos de España, te molesta si te mando un privado para hablar en castellano??

Naturalmente que no, cuando gustes puedes mandarme un mensaje :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...