Bradley wrote:
Aldo Foot wrote:
On Wed, Sep 24, 2008 at 12:58 PM, Bradley <pursley001@xxxxxxxxxxx> wrote:
Okay,
I am starting to do some more advanced automated maintenance on my
system but can't find a nifty way to do something and was wondering if
anyone out there can help me with this. I am configuring my system to
do an automated backup of all my data (2 to 4 hours per week) but need
it to do certain things to protect the process.
For an unattended process, I need to know how to:
1. Force all users currently logged on to be logged off (preferably
with at least a 5 minute notice).
2. Prevent anyone from logging on.
3. Prevent the system from being shut down or rebooted.
4. Shut down the X server (speeds up processing time considerably).
5. After finished to restart X server and allow shutdown and logins.
If anyone knows any commands to do at least some of these, I would
appreciate knowing how. The part about shutting down the X server is
optional but would be nice but not allowing anyone to be logged in and
preventing system shut down is necessary.
Bradley
My 0.02 cents.
start by doing man on login, nologin, shutdown, killall etc...
/etc/nologin -- prevents user logins
shutdown -k Don't really shutdown; only send the warning messages
to everybody.
killall -u, --user
Kill only processes the specified user owns.
Command names are
optional.
~af
Thanks for the input but, unfortunately, this doesn't give the results
that I need.
I gave up and configured one of the run levels for doing the needed
tasks and have the system reboot into that run level where it does what
I need it to and then reboots the system back to the normal run level.
Not a pretty arrangement but it seems to work. While in the special run
level, it does not activate any unnecessary services (network, servers,
Xserver, etc.) and does not allow any user logins. This turned out to
be simpler and cleaner to set up than what I had previously considered.
Here's a script that might do what you want:
--------------------------- CUT HERE -----------------------------------
#!/bin/bash
# Send a message to all users...
wall The system will be shutting down in five minutes. Please log off now!
# Prevent new logins...
echo "Logins temporarily disabled" >/etc/nologin
# Wait 5 minutes...
sleep 300
# Log off all users...
for USER in `who | cut -d " " -f 1`; do if [ $USER != "root" ]; then
killall -u $USER; fi; done
# Shut down X by going to run level 3...
telinit 3
echo "System quiescent...ready for updates"
echo -n "Press the ENTER key when you want to return to normal: "
read USERINPUT
# Re-enable logins...
rm -f /etc/nologin
# Restart X...
telinit 5
telinit Q
echo "System returned to normal"
exit 0
--------------------------- CUT HERE -----------------------------------
This script must be run as root in a virtual console (ALT-F1, ALT-F2,
etc.--NOT an xterm). It may break at the "telinit 3" bit (I think it'll
continue to run). I've not tested it, but there's nothing particularly
dangerous about it.
Note that there's no way to prevent reboots or shutdowns. Normally,
CTRL-ALT-DEL will do a soft shutdown/reboot. You can change that to a
hard reboot (no syncing of dirty disk buffers, etc.), but you can't stop
it.
----------------------------------------------------------------------
- Rick Stevens, Systems Engineer ricks@xxxxxxxx -
- AIM/Skype: therps2 ICQ: 22643734 Yahoo: origrps2 -
- -
- Programmers often confuse Halloween and Christmas. -
- After all, 31 Oct is the same as 25 Dec! -
----------------------------------------------------------------------
--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines