WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Inactivity Timed Shutdown in Shell  (Read 982 times)

Offline Boss 429

  • WikiUser
  • *
  • Posts: 22
Inactivity Timed Shutdown in Shell
« on: May 11, 2017, 07:14:39 AM »
I have been digging around in the forums looking for a way to shut down Linux in shell after a period of inactivity. I found this thread from 2014: http://forum.tinycorelinux.net/index.php/topic,17830.0.html. I used the code Rich provided, and it seems to almost work. When it is executed, it says that it doesn't find xset (probably because there is no "X" installed on this machine). I just need something I can point to that will consistently say the pc is inactive, or that there have been no keystrokes after a period of time, in shell.

Thank you

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1530
Re: Inactivity Timed Shutdown in Shell
« Reply #1 on: May 11, 2017, 07:31:28 AM »
xset  is provided by  Xlibs.tcz .
Including its deps it's 3.09 MB.
Download a copy and keep it handy: Core book ;)

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 9479
Re: Inactivity Timed Shutdown in Shell
« Reply #2 on: May 11, 2017, 09:41:48 AM »
For a cli-only setup, try "w" from procps.tcz.
The only barriers that can stop you are the ones you create yourself.

Offline Boss 429

  • WikiUser
  • *
  • Posts: 22
Re: Inactivity Timed Shutdown in Shell
« Reply #3 on: May 15, 2017, 06:24:05 AM »
I have downloaded and installed Xlibs.tcz. when I try to run Xset -s it is giving me the error "xset: unable to open display "" "

I also tried downloading procps.tcz, and it is giving me an error saying file not found.

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1530
Re: Inactivity Timed Shutdown in Shell
« Reply #4 on: May 15, 2017, 06:48:48 AM »
Oops, sorry. Kinda makes sense that xset can't set properties of X when there is no X. :p
Download a copy and keep it handy: Core book ;)

Offline Boss 429

  • WikiUser
  • *
  • Posts: 22
Re: Inactivity Timed Shutdown in Shell
« Reply #5 on: May 15, 2017, 07:35:39 AM »
Is there a way it will work without X?

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1530
Re: Inactivity Timed Shutdown in Shell
« Reply #6 on: May 16, 2017, 02:33:25 AM »
I also tried downloading procps.tcz, and it is giving me an error saying file not found.
On tc-7.x x86  procps.tcz  contains  /usr/local/bin/w .
Download a copy and keep it handy: Core book ;)

Offline Boss 429

  • WikiUser
  • *
  • Posts: 22
Re: Inactivity Timed Shutdown in Shell
« Reply #7 on: May 17, 2017, 04:43:20 AM »
So, referring back to what Rich had provided for code in the other thread, how would I go about making it shut down after 5 hours? I'm not sure how I need to set up the code and what exactly it will need to look at in order for it to work properly.

Offline Boss 429

  • WikiUser
  • *
  • Posts: 22
Re: Inactivity Timed Shutdown in Shell
« Reply #8 on: May 23, 2017, 04:51:16 AM »
I've looked into it a little more, I'm still not having a lot of luck getting it to work..

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1530
Re: Inactivity Timed Shutdown in Shell
« Reply #9 on: May 23, 2017, 05:31:05 AM »
Code: [Select]
tce-load -i procps
watch w
You should see the  IDLE  value increasing.
Download a copy and keep it handy: Core book ;)

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1530
Re: Inactivity Timed Shutdown in Shell
« Reply #10 on: May 23, 2017, 05:35:36 AM »
Maybe something like
Code: [Select]
w -hs | awk '/tty1/ {print $3}'
Download a copy and keep it handy: Core book ;)

Offline Boss 429

  • WikiUser
  • *
  • Posts: 22
Re: Inactivity Timed Shutdown in Shell
« Reply #11 on: May 23, 2017, 06:12:42 AM »
when I try to run

Code: [Select]
tce-load -I procps
I'm getting a not found error. Is there another package I need to have downloaded prior to trying to run that code?

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 9479
Re: Inactivity Timed Shutdown in Shell
« Reply #12 on: May 23, 2017, 10:41:33 AM »
You don't mention your version and arch. We assume the latest on x86, where procps is available.
The only barriers that can stop you are the ones you create yourself.

Offline Boss 429

  • WikiUser
  • *
  • Posts: 22
Re: Inactivity Timed Shutdown in Shell
« Reply #13 on: May 23, 2017, 11:17:50 AM »
My apologies, I'm running PiCore 9.0 on a couple (including the test machine), and Core 7.2 on the others. Would like to have it working on both if possible..

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 9479
Re: Inactivity Timed Shutdown in Shell
« Reply #14 on: May 24, 2017, 03:31:32 AM »
procps-ng seems to be available there, it has the same command.
The only barriers that can stop you are the ones you create yourself.