[Durham] Bash Scripting
h.p.griffiths at gmail.com
Mon Dec 17 01:02:56 UTC 2012
What you need to find out is:
1) How well your mobo and Linux kernel handles suspending and unsuspending. (I have ~150 machines at work that will not wake up by any means if suspended and have to be power-cycled to make them useable again, so this might scupper you.)
2) What command-line programs SAMBA provides for seeing what files are open by remote users and what output and exit codes the programs return when the number of users is zero.
3) As (2), but for whatever the AFP service suite is called.
Bash will let you call programs and examine exit codes from the last run program directly; to examine output messages, you can use grep to see whether a pre-determined pattern was found in the output. A guide for exit code testing: http://linuxcommando.blogspot.co.uk/2008/03/how-to-check-exit-status-code.html. You will also need to set up an entry in /etc/crontab (or put your script in the right /etc/cron folder) to make it happen every hour/day/whenever.
If this is to run on a machine that's mission-critical, you need to test a lot and be sure that your kernel handles suspending and wake on LAN properly every time, but also think carefully about whether the risk of having the machine not wake up is worth the power saving. You also need to be aware that your script might no longer be safe after a kernel patch or change of *any* piece of hardware (I had a mouse once that wouldn't work after my pc had been suspended and woken up (the led went out and wouldn't come back on) yet this mouse was fine with a different mobo), so updates or repairs will require you to turn off the script until you can test it again.
On 16 Dec 2012, at 21:48, Andrew Glass <andrewglass3 at gmail.com> wrote:
> Can you help me please?
> Ive never done bash scripting before however id like to write a simple script that would check for active afp users/smb users and if its idle for the machine to sleep - if there are active users it does nothing. Id also like this machine to wake from lan. Im using an intel pro 1000 gigabit eth card.
> Any advice would be most gratefully welcomed :)
> Durham mailing list - Durham at mailman.lug.org.uk
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Durham