WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Set Shutdown Time  (Read 1018 times)

Offline Boss 429

  • WikiUser
  • *
  • Posts: 22
Set Shutdown Time
« on: April 28, 2017, 06:32:15 AM »
Hi,

I've been searching the forums and I'm not really seeing a way to shut down TC at a specific time. I would like to be able to shut the machines down at night without having to interact with them. The closest thing I've found was setting up a delay timer, but that won't quite work for my application.

Thank you

Offline netnomad

  • Hero Member
  • *****
  • Posts: 1027
Re: Set Shutdown Time
« Reply #1 on: April 28, 2017, 06:54:55 AM »
hi,

you are looking for a tool like cron.
with cron-jobs you can define timetables for commands f.e. shutdown at a specific time.

keep on hacking :-)

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1587
Re: Set Shutdown Time
« Reply #2 on: April 28, 2017, 07:38:35 AM »
You can use the  cron  bot code to start cron at boot.
The command  crontab -e  is used to create a cron job. An editor will open where you can write in something like this:
Code: [Select]
00 00 * * * /usr/bin/filetool.sh -b ; /usr/bin/sudo /sbin/poweroff
This would, at midnight, perform a backup and shutdown the system.

Then add  var/spool/cron/crontabs  to your backup.
Download a copy and keep it handy: Core book ;)

Offline Boss 429

  • WikiUser
  • *
  • Posts: 22
Re: Set Shutdown Time
« Reply #3 on: May 01, 2017, 11:36:24 AM »
Misalf, When I tried to insert the code into crontab, it wouldn't allow me to run a backup, and the next line of text started to jump across the screen every time I hit the return key to go to the next line. I'm not really sure what would be causing that, but it's consistently doing it

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4249
Re: Set Shutdown Time
« Reply #4 on: May 01, 2017, 01:01:06 PM »
Do not use leading "/" in .filetool.lst.

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1587
Re: Set Shutdown Time
« Reply #5 on: May 01, 2017, 04:56:02 PM »
Works here.
Are you familiar with the  vi  editor? It can be quite confusing to use. Maybe that's what happened?
Download a copy and keep it handy: Core book ;)

Offline Boss 429

  • WikiUser
  • *
  • Posts: 22
Re: Set Shutdown Time
« Reply #6 on: May 02, 2017, 11:25:30 AM »
I'm fairly familiar with vi editor. I'm just not sure if I'm saving it with the wrong extension? maybe the wrong location? I have entered the code as you have it in your previous post. I get a notification on boot that Crond is running as well.

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1587
Re: Set Shutdown Time
« Reply #7 on: May 02, 2017, 11:38:58 AM »
I'm just not sure if I'm saving it with the wrong extension? maybe the wrong location?
With  crontab -e , an editor opens with a temporary file name which must not be changed nor must the location be specified; cron takes care about that.
Download a copy and keep it handy: Core book ;)

Offline patrikg

  • Sr. Member
  • ****
  • Posts: 287
Re: Set Shutdown Time
« Reply #8 on: May 02, 2017, 12:10:11 PM »
In lots of Linux dists. You can set the EDITOR environment variable.
So
Code: (bash) [Select]
crontab -e
can use that, instead of the default vi.

Code: (bash) [Select]
export EDITOR=nano

Offline Boss 429

  • WikiUser
  • *
  • Posts: 22
Re: Set Shutdown Time
« Reply #9 on: May 03, 2017, 06:49:24 AM »
I'm sorry for the poor quality, my camera wouldn't focus and I'm not sure how to take screenshots in TC.. but every time I run crontab -e, this is what happens when I close the command. I'm not sure why it's doing this. I even tried a fresh install of TC just to make sure that it wasn't something that I might have caused.

Online Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 5471
Re: Set Shutdown Time
« Reply #10 on: May 03, 2017, 07:10:55 AM »
Hi Boss 429
It appears to be executing a  find  command upon returning to the command prompt for some reason. Also the carriage
returns are behaving like just linefeeds.


Offline Boss 429

  • WikiUser
  • *
  • Posts: 22
Re: Set Shutdown Time
« Reply #11 on: May 03, 2017, 07:29:35 AM »
I ran the find command to show what it was doing, and when I try to run the backup command, it won't let me. it will more or less "lock up" and not let me do anything unless I reboot

Online Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 5471
Re: Set Shutdown Time
« Reply #12 on: May 03, 2017, 09:18:51 AM »
Hi Boss 429
I see, so if you were to just hit enter a bunch of times the prompt would keep shifting down 1 line and to the right by
the width of the prompt. I've seen that behavior when a program launched from a terminal crashes or misbehaves. I
close the terminal and open a new one in that case.

Offline Boss 429

  • WikiUser
  • *
  • Posts: 22
Re: Set Shutdown Time
« Reply #13 on: May 03, 2017, 09:52:49 AM »
That's exactly what it's doing. Would I just need to run the "exit" command and log back to in to piCore to do so? I'm not using a GUI interface

Online Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 5471
Re: Set Shutdown Time
« Reply #14 on: May 03, 2017, 10:38:15 AM »
Hi Boss 429
That's certainly worth giving a try.