Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 17 Nov 2017, 17:14
All times are UTC - 4
 Forum index » House Training » Users ( For the regulars )
How to shutdown the pc on a specific time on terminal?
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [9 Posts]  
Author Message
lolo69

Joined: 01 Oct 2017
Posts: 10

PostPosted: Fri 10 Nov 2017, 21:54    Post subject:  How to shutdown the pc on a specific time on terminal?  

A script or even an app to "poweroff" the pc at a specific time?

really need it.

please some help.
Back to top
View user's profile Send private message 
Galbi


Joined: 21 Sep 2011
Posts: 941
Location: Bs.As. - Argentina.

PostPosted: Sat 11 Nov 2017, 08:26    Post subject:  

https://www.computerhope.com/unix/ushutdow.htm
_________________
Remember: "pecunia pecuniam parere non potest"
Back to top
View user's profile Send private message 
Mike Walsh


Joined: 28 Jun 2014
Posts: 3131
Location: King's Lynn, UK.

PostPosted: Sun 12 Nov 2017, 06:59    Post subject:  

Hi, lolo69.

Amongst the stuff I keep in my 'Puppy-Stuff' data partition, I have a couple of small scripts for those occasions when I want to shut Pup down after a given interval. One is for 30 minutes, the other is for 60 mins. It is, however, a very simple matter to edit the script and substitute the number of minutes required, in order to shut Pup down at the time you want.

Here's the 30-minute one:-

Code:
#!/bin/sh
sleep 30m && wmpoweroff &


Open Geany, copy'n'paste that into it, then save it with a name you'll recognise. I find the best place to keep it is in /root. Make sure you've made it executable; easiest way is just to rt-clk->Properties, then tick the 'Execute' checkboxes down the bottom, followed by clicking on 'Refresh'. The 'Run action' will change to 'execute', and the script title will change from black text to green.....indicating it's now executable (although using the '#!/bin/sh' prefix on the first line should save it as executable anyway).

To change the value, rt-clk->Open as text, or Open with Geany. Geany should open with the contents of the script. Edit accordingly.....and don't forget to 'Save' before you close Geany.

Hope that helps. You could enter that direct into the terminal.....but you would have to re-type it every time. A script allows the same action to be used again & again, just by clicking on it.

Whenever you need it, just open it in Geany, modify the value accordingly, 'Save', exit.....then click on it. Simple.

-----------------------

@Galbi:-

I think you'll find the instructions on that page you linked to would work fine for mainstream Linux distros.....but of course, we all know Pup is far from being 'mainstream'.

The code I've quoted I discovered here on the Forum somewhere; I forget where, but I know it was quite an old post... It does, however, work perfectly for the inhabitants of my kennels!


Mike. Wink

_________________
If I've helped you.....please say 'Thanks'!
MY PUPPY PACKAGES
--------------------------------------

Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1389
Location: Japan

PostPosted: Sun 12 Nov 2017, 07:44    Post subject: Re: How to shutdown the pc on a specific time on terminal?  

lolo69 wrote:
A script or even an app to "poweroff" the pc at a specific time?
If you want to shut down at a specific time (and not after an elapsed time) you could try Pschedule. I don't know your Slacko 6.3 but you may find Pschedule in Menu => System => Pschedule task on time.

Click on "Schedule new task", in the Command field type wmpoweroff, select the desired time for this task and add it to the task list. That should be all.

I'm not sure what "on terminal" in your thread title means. Pschedule is a graphical front-end to create cron jobs. If you really want to use the terminal then Pschedule is not for you. Still I would recommend that you don't mess with crontab files on the command line.
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 2584
Location: holland

PostPosted: Sun 12 Nov 2017, 11:19    Post subject:  

You can use the "at" command, probably not included in any puppy, but you can install it, see here Ubuntu-Trusty packages
https://packages.ubuntu.com/trusty/admin/at

Then, for example, if you want to poweroff the computer at quarter past five:
Code:
echo "poweroff" | at 17:15


Fred

_________________
Dog Linux website
Back to top
View user's profile Send private message 
Mike Walsh


Joined: 28 Jun 2014
Posts: 3131
Location: King's Lynn, UK.

PostPosted: Sun 12 Nov 2017, 19:31    Post subject: Re: How to shutdown the pc on a specific time on terminal?  

MochiMoppel wrote:
lolo69 wrote:
A script or even an app to "poweroff" the pc at a specific time?
If you want to shut down at a specific time (and not after an elapsed time) you could try Pschedule. I don't know your Slacko 6.3 but you may find Pschedule in Menu => System => Pschedule task on time.

Click on "Schedule new task", in the Command field type wmpoweroff, select the desired time for this task and add it to the task list. That should be all.

I'm not sure what "on terminal" in your thread title means. Pschedule is a graphical front-end to create cron jobs. If you really want to use the terminal then Pschedule is not for you. Still I would recommend that you don't mess with crontab files on the command line.


Thanks for the tip on this one, MochiMoppel. I've occasionally looked at this, but never really figured out what it was for.

Now I know! Cheers.


Mike. Wink

_________________
If I've helped you.....please say 'Thanks'!
MY PUPPY PACKAGES
--------------------------------------

Back to top
View user's profile Send private message Visit poster's website 
theru

Joined: 23 Jul 2015
Posts: 149
Location: Heers, Belgium

PostPosted: Mon 13 Nov 2017, 13:27    Post subject:  

This worked for a reboot command in a terminal window

Code:
while :; do if [[ $(date +%R) =~ 18:18 ]] ; then reboot ; else sleep 5 ; fi ; done


So a script would be something like


Code:
#!/bin/sh

shutdowntime=18:18

while :; do if [[ $(date +%R) =~ $shutdowntime ]] ; then reboot ; else sleep 30 ; fi ; done


Haven't tested it as a script but it should work the same way
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 2584
Location: holland

PostPosted: Mon 13 Nov 2017, 18:54    Post subject:  

theru wrote:
This worked for a reboot command in a terminal window

Code:
while :; do if [[ $(date +%R) =~ 18:18 ]] ; then reboot ; else sleep 5 ; fi ; done


So a script would be something like


Code:
#!/bin/sh

shutdowntime=18:18

while :; do if [[ $(date +%R) =~ $shutdowntime ]] ; then reboot ; else sleep 30 ; fi ; done


Haven't tested it as a script but it should work the same way


Works well, nice solution, thanks!

EDIT: For info, just in case someone wants to try this with another command instead of "reboot", for example firefox, make sure to add 'exec' before it, e.g. :
Code:
while :; do if [[ $(date +%R) =~ 18:18 ]] ; then exec firefox ; else sleep 5 ; fi ; done


Fred

_________________
Dog Linux website
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1389
Location: Japan

PostPosted: Mon 13 Nov 2017, 22:23    Post subject:  

Code:
#!/bin/sh
EXEC_START=18:05:30                                   # '18:00' or just '18' would start command at 6 p.m.
sleep $(( $(date -d $EXEC_START +%s) - $(date +%s) )) # sleeps until 18:05:30
Xdialog -msg "$(date +%X)\nTime to do something" x    # sample command
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [9 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0886s ][ Queries: 11 (0.0050s) ][ GZIP on ]