6 replies
by fanakart
Just put the following line in root's crontab (crontab -e while logged in as root):
0 1 * * * (/sbin/shutdown -r) > /dev/null 2>&1
This reboot the system at 1:00, thus kicking users out. But this will not prevent them from logging back (if theyare around at 1AM).
You could fiddle with the /etc/nologin file that prevents users logins but this file is erased at boot.
Hope this helps.
Denis
by ronmc
by ronmc
I appreciate your answer. I was looking for something a little less radical than re-booting every night. However, if no one else has a better idea, I might use this.
Thanks
by fanakart
Ron,
Rebooting before a backup is always the safest way to go because it closes every open file.
But if you can't stop some process (database server or some other job that must run at night) then you can do something like this:
# get sorteduser list without root
for user in $(who | awk '$1 != "root" {print $1}' | sort -u); do
# kill nicely every process of every user
kill $(ps -fu denbea|awk 'NR > 1 {print $2}')
sleep 30
# kill every process of every user
kill -9 $(ps -fu denbea|awk 'NR > 1 {print $2}')
done
by ronmc
I think you might be right about the reboot every night. I think I'll try it.
Thank you for your help.
by ronmc
This discussion is closed to new replies.
Trending Linux posts
Sort by Trending