PDA

View Full Version : Shutdown computer program or script




grapes911
Mar 19, 2005, 01:44 PM
I have a lab full of Macs running 10.3.8. I need to shut them all down at night. Every night has a different time. I have users on these machines that just don't leave at closing.

Solution:
I will have a script that is basically "shutdown -h now", and run it from the cron tab. I also need some type of popup reminding people of closing at 20mins, 10mins, 5mins, and 1min.

Problems:
1. People may reboot the computer. I could shutdown the computer every minute for the next 10 minutes or so, until users get the idea. This is dirty, but it will work.

2. I use anacron. If the computer is already off, will the computer shutdown when it comes back off? Can anacron take over some cron scripts and not others?

3. In rare instances, I may need to stop the shutdown. Not all the lab monitors are terminal savvy, so I need an easy way to turn it off. I was thinking of writing a basic program that cron could run. One the last popup window there could be a password field to override shutdown, but I figured this could be forced quit pretty easily.

Anyone have an input or ideas?



Mechcozmo
Mar 19, 2005, 02:12 PM
I guess you've thought of the Schedule feature in Panther under Energy Saver? It will prompt the user to save all files, then shut down the computer. I guess there is the issue of people restarting the computer, but setting up a cron script to run 5 minutes after the computer is supposed to have shut down to shut it down again might work.

If you have a server, can you kick users off? Never used OS X server.... just thinking here...

grapes911
Mar 19, 2005, 03:25 PM
I guess you've thought of the Schedule feature in Panther under Energy Saver? It will prompt the user to save all files, then shut down the computer. I guess there is the issue of people restarting the computer, but setting up a cron script to run 5 minutes after the computer is supposed to have shut down to shut it down again might work.

If you have a server, can you kick users off? Never used OS X server.... just thinking here...

I have thought about the Energy Saver Scheduler. It doesn't have enough controll. I need different times for each day. Plus, its too easy to turn off.

I have a storage server, but they can run most things locally.

Mechcozmo
Mar 19, 2005, 04:28 PM
I have thought about the Energy Saver Scheduler. It doesn't have enough controll. I need different times for each day. Plus, its too easy to turn off.

I have a storage server, but they can run most things locally.

You can lock the Energy Saver so they can't make changes. Only an admin can click the lock and change the settings if you do that. And I think you can AppleScript it, but I'm not sure. Something to look into.

Ah, well then I guess you aren't using OS X server to admin the computers...

grapes911
Mar 19, 2005, 04:31 PM
You can lock the Energy Saver so they can't make changes. Only an admin can click the lock and change the settings if you do that. And I think you can AppleScript it, but I'm not sure. Something to look into. That would work, but is there anyway to make it shutdown at different times each day?

dotdotdot
Mar 19, 2005, 04:43 PM
Well how many computers?

My school has one person walking around manually shutting down machines...

You can Password protect the computers and lock the Energy saver thing so no one can turn the computer on again except for people w/ the password, etc...

Maybe there is a 'computer alarm clock?' i think windows may have this feature!

dotdotdot
Mar 19, 2005, 04:45 PM
Windows has a program you can download: Active Shutdown - check if this is available for the Mac

grapes911
Mar 19, 2005, 04:53 PM
Well how many computers?

My school has one person walking around manually shutting down machines...

You can Password protect the computers and lock the Energy saver thing so no one can turn the computer on again except for people w/ the password, etc...

Maybe there is a 'computer alarm clock?' i think windows may have this feature!

About 40 computers. People do walk around shutting them down. Its just that the users get really pissy and we have had incidents where people resort to violence to keep someone from turing off the computer. Security had to come and remove users twice in the last year. Its just a few users over and over again. If the process what automated, (like 'shutdown -h now') it should help the site assistants. I just need more control than a simple 'shutdown -h now'.

Password protecting the computers would be a no. User Services (who controls the lab says we aren't to turn on computers. Once a user turns it on, we can keep it on till close. Its some stupid PC energy conservation things. It would be very annoying to enter a password everytime someone wanted a computer turned on.

Mechcozmo
Mar 19, 2005, 04:58 PM
Simple solution!

Have the computers shut down at a certain time. Say, 2100

At 2105 a cron script runs that shuts down again (just in case)

You walk around and take power cables away. At 2110 again a cron runs (if you need that much time to pull cables out of the computers).

Lock cables in a cabinet. Done. Can't start them up like that.

grapes911
Mar 19, 2005, 05:15 PM
Simple solution!

Have the computers shut down at a certain time. Say, 2100

At 2105 a cron script runs that shuts down again (just in case)

You walk around and take power cables away. At 2110 again a cron runs (if you need that much time to pull cables out of the computers).

Lock cables in a cabinet. Done. Can't start them up like that.

Taking the power cables away is not a viable soluton.

And thank you for trying, but you went right back to the begining. A simple script is not enough. I need control over the script/program to abort it in rare occations. Plus anacron would turn off the computers as soon as they started if there was still a shutdown command left. Not Done.

Now back to my original question, I'll simplify it:
If anyone has an idea on how to stop a script by use password and not using the terminal, please help me.
If anyone has an idea on how to catch a force quit command, please help me.

Dippo
Mar 20, 2005, 12:25 AM
This won't answer your original question, but if having people reboot the computers is a problem, then a program could be run on startup. The program could check and see how long it has been since the force shutdown (or just check what time of day it is). And then the program can automatically shutdown again or not let the users logon.

If these were Windows machines, then I could help more...alas.

grapes911
Mar 20, 2005, 09:23 AM
This won't answer your original question, but if having people reboot the computers is a problem, then a program could be run on startup. The program could check and see how long it has been since the force shutdown (or just check what time of day it is). And then the program can automatically shutdown again or not let the users logon.

If these were Windows machines, then I could help more...alas.

This is what I want to do. I'm just now sure exactly how. I have a good amout of programing experience, I just don't know where to start. If this were linux, I'd have the rc files check for time of day and not allow the boot. I just don't think its a good idea to touch the rc files on a mac.

Mechcozmo
Mar 20, 2005, 05:29 PM
This is what I want to do. I'm just now sure exactly how. I have a good amout of programing experience, I just don't know where to start. If this were linux, I'd have the rc files check for time of day and not allow the boot. I just don't think its a good idea to touch the rc files on a mac.

Can't you write a program that, on startup:
-Writes a file owned by an admin to the hard drive somewhere and writes to it again on shut down
-Checks to see if the last shut down time written was. If it was over X hours ago, then it allows you to continue starting up. If the last shut down time was only a short while ago, it gives you a box that allows you to enter an administrator's password or click on a "Shut Down" button.

So say someone restarts a computer when they weren't supposed to. Upon startup (after the OS has been initialized and before the login screen is a System Startup Items, and after you log in are Login Items. There is a difference between the two-- you want to make a System Startup Item) the program checks this file. Because it has been less than a specified amount of time, the program asks them to either enter an Administrator password or click on Shut Down. If they enter the password (say you are troubleshooting) then it allows the login window to appear. If they don't, they must shutdown. Or it will shut down automatically after 5 minutes.

GeeYouEye
Mar 20, 2005, 07:53 PM
You could install something that I think is called MacSMBPop (or something like that) that works like the smbclient message pop-ups on windows, to warn people that the computers will be shut down in X minutes, use the shutdown -h now (or whatever it was) command, and once it's done, kill the power at the circuit breaker. No one will reboot after that. >:D

jdogg
Oct 7, 2005, 06:44 PM
http://softwares.bajram.com/utilities/#Super_Shut_Down
its a beta though it has a timer and all u need and want enjoy and i hope it helps!!


p.s i had to register to post this lol :)) hahha



{peace}

grapes911
Oct 9, 2005, 11:52 AM
Thanks for trying, but this is not what I wanted at all. It it too easy to cancel (unless I'm missing something). I needed a program that would shutdown the computers so to get the users off them.

I already wrote a program that satisfies my needs. Thanks anyway.

forbade
May 1, 2007, 01:42 PM
Thanks for trying, but this is not what I wanted at all. It it too easy to cancel (unless I'm missing something). I needed a program that would shutdown the computers so to get the users off them.

I already wrote a program that satisfies my needs. Thanks anyway.

:apple:

you could ssh "osascript" commands to execute an applescript on the remote client(s) that will force it to shut down. plus with ssh and osascript you can perform other options as well. Like display whatever dialog you want etc etc.
This also lets you start the shut down process on command if you wish.

if you needed to cancel, the shutdown command (from the cron or even if activated by a remote shell) just kill the PID. :)

umm. depending on how many computers you administer, would depend on the complexity up the master script from the server.

just ssh to a sudo account on the remote system(s) and execute the osascript you desire. fun fun. :)

ChrisA
May 1, 2007, 06:27 PM
Wire the computers into electric outlets controled by "X10". then after the "shutdown -h" command runs you send a "power off" to the X10 outlets. The AC power is dead so the computers can't be turned back on.

grapes911
May 1, 2007, 06:35 PM
Holy Crap!!! Thanks for the advice, but this thread is from 2005!!! I haven't worked there in almost a year. forbade, the the heck did you dig this thing up?