Automatic shutdown - Suse

This is a discussion on Automatic shutdown - Suse ; I have some PCs that are not in regular use at the moment. Still they should be included in the backup, get their patches and stay up to date as far as the network configuration is concerned. So they receive ...

+ Reply to Thread
Results 1 to 10 of 10

Thread: Automatic shutdown

  1. Automatic shutdown

    I have some PCs that are not in regular use at the moment. Still they
    should be included in the backup, get their patches and stay up to date
    as far as the network configuration is concerned. So they receive a
    wake on LAN call every night at backup time and shut down two hours
    later triggered by a crontab entry. Cron.daily cares about the updates.
    Instead of the shutdown at a fixed time by crond I would like them to
    configure such that they shut down automatically provided that
    - uptime is at least two hours
    - nobody is logged in
    - no backup job is running (amanda)
    - load is below a given threshold
    Is there an simple way to accomplish this with openSuSE? I know about
    kPowersave. But this is based on user settings which are not of
    interest here. I also prefer init 0 to suspend or hibernate. The
    additional boot time is not relevant in this case.

    GŁnther

  2. Re: Automatic shutdown

    GŁnther Schwarz wrote:
    > I have some PCs that are not in regular use at the moment. Still they
    > should be included in the backup, get their patches and stay up to date
    > as far as the network configuration is concerned. So they receive a
    > wake on LAN call every night at backup time and shut down two hours
    > later triggered by a crontab entry. Cron.daily cares about the updates.
    > Instead of the shutdown at a fixed time by crond I would like them to
    > configure such that they shut down automatically provided that
    > - uptime is at least two hours
    > - nobody is logged in
    > - no backup job is running (amanda)
    > - load is below a given threshold
    > Is there an simple way to accomplish this with openSuSE? I know about
    > kPowersave. But this is based on user settings which are not of
    > interest here. I also prefer init 0 to suspend or hibernate. The
    > additional boot time is not relevant in this case.


    It depends on 'simple'. First: why do you need 2 hours uptime? I asume
    you do this so the updates are done. This can either be too long (in
    most cases) or not long enough if there is a problem with the connection
    and it is slowed down.

    What I would do is write a bash script that does the following:
    #!/bin/bash
    run_backup
    run_update
    run_shutdown

    The first should be fairly easy. The second as well. The advantage is
    that the second waits for the first to finish. next the update is done
    and only after the update is done, do you start the shutdown.

    That part can do several things, some you might not need
    1) See what time it is. Shutting down at 8:30 when people start working
    at 8:45 is silly.
    2) See if anybody is still logged in
    2a) See if they were idle for 2 hours or more)
    2b) See what programs they are running
    3) check the load
    4) Look back every 15 minutes

    This can be made as easy and as complicated as you desire.

    The advantage of running a script is that it itself will see that it
    waits for program A to finish before it starts with program B. The real
    chalange will be what to do with errors. If there is no
    networkconnection to the Interweb, should it continue with the update,
    wait adn try again, do the backup first and then the update?
    What if the backup gives problems?

    houghi
    --
    If God doesn't destroy Hollywood Boulevard, he owes Sodom and
    Gomorrah an apology.

  3. Re: Automatic shutdown

    =?ISO-8859-1?Q?G=FCnther?= Schwarz writes:

    >I have some PCs that are not in regular use at the moment. Still they
    >should be included in the backup, get their patches and stay up to date
    >as far as the network configuration is concerned. So they receive a
    >wake on LAN call every night at backup time and shut down two hours
    >later triggered by a crontab entry. Cron.daily cares about the updates.
    >Instead of the shutdown at a fixed time by crond I would like them to
    >configure such that they shut down automatically provided that
    >- uptime is at least two hours
    >- nobody is logged in
    >- no backup job is running (amanda)
    >- load is below a given threshold


    Run at jobs instead. Set it up so an at job is aunched at startup for 2
    hours from then, and then that atjob looks at the job list and decides
    if the conditions are met. If not the job is rerun in 5 min, if conditions
    are met the system is shutdown.

    >Is there an simple way to accomplish this with openSuSE? I know about
    >kPowersave. But this is based on user settings which are not of
    >interest here. I also prefer init 0 to suspend or hibernate. The
    >additional boot time is not relevant in this case.


    >GŁnther


  4. Re: Automatic shutdown

    houghi wrote:

    > GŁnther Schwarz wrote:
    >> I have some PCs that are not in regular use at the moment. Still they
    >> should be included in the backup, get their patches and stay up to
    >> date as far as the network configuration is concerned. So they
    >> receive a wake on LAN call every night at backup time and shut down
    >> two hours later triggered by a crontab entry. Cron.daily cares about
    >> the updates. Instead of the shutdown at a fixed time by crond I would
    >> like them to configure such that they shut down automatically
    >> provided that - uptime is at least two hours
    >> - nobody is logged in
    >> - no backup job is running (amanda)
    >> - load is below a given threshold
    >> Is there an simple way to accomplish this with openSuSE? I know about
    >> kPowersave. But this is based on user settings which are not of
    >> interest here. I also prefer init 0 to suspend or hibernate. The
    >> additional boot time is not relevant in this case.

    >
    > It depends on 'simple'. First: why do you need 2 hours uptime? I asume
    > you do this so the updates are done. This can either be too long (in
    > most cases) or not long enough if there is a problem with the
    > connection and it is slowed down.


    Yes, it is a networked backup where the process is initiated by the
    backup server via xinetd. So the client has to wait until the server
    calls. But it is rather well balanced and two hours are plenty for this
    specific network.

    The proper solution would be to hack the amanda backup software so that
    the server sets a wol command prior to initiate the backup process on a
    given client. But I won't go into this as it is simply much to much
    hazzle and I simply can't see how this could be done easily (same with
    PCs running server processes like nfs which are up 7/24 because my
    autofs script has no capability to wake up machines on request).

    > What I would do is write a bash script that does the following:
    > #!/bin/bash
    > run_backup
    > run_update
    > run_shutdown


    I could indeed replace the crontab entry '30 3 * * * root shutdown -h
    now' with a more sophisticated script taking these and more additional
    conditions into account. But then I was asking for a simple solutions
    that does not need much scripting work to be done.

    > The advantage of running a script is that it itself will see that it
    > waits for program A to finish before it starts with program B. The
    > real chalange will be what to do with errors. If there is no
    > networkconnection to the Interweb, should it continue with the update,
    > wait adn try again, do the backup first and then the update?
    > What if the backup gives problems?


    If the backup fails one night it will most likely complete the next one
    without problems. So this is not really a concern as long as backups
    are running nicely most of the time. I check the logs on the backup
    server on a daily basis, so I'm well aware of was is going on. Also the
    update script does send an email upon completion.

    GŁnther

  5. Re: Automatic shutdown

    Unruh wrote:

    > =?ISO-8859-1?Q?G=FCnther?= Schwarz writes:
    >
    >>I have some PCs that are not in regular use at the moment. Still they
    >>should be included in the backup, get their patches and stay up to
    >>date as far as the network configuration is concerned. So they receive
    >>a wake on LAN call every night at backup time and shut down two hours
    >>later triggered by a crontab entry. Cron.daily cares about the
    >>updates. Instead of the shutdown at a fixed time by crond I would like
    >>them to configure such that they shut down automatically provided that
    >>- uptime is at least two hours
    >>- nobody is logged in
    >>- no backup job is running (amanda)
    >>- load is below a given threshold

    >
    > Run at jobs instead. Set it up so an at job is aunched at startup for
    > 2 hours from then, and then that atjob looks at the job list and
    > decides if the conditions are met. If not the job is rerun in 5 min,
    > if conditions are met the system is shutdown.


    I'm not sure if I get this right: you propose to run an at job calling
    an at job and so on? I would rather place a script checking for uptime
    and other conditions in cron.hourly instead, right? But then I was
    asking for a built in solution hiding somewhere in the mysteries of
    SuSE's /etc/syconfig. Obviously there is no such thing. So I might well
    live with the current quick'n dirty solution or write a proper script
    myself placing this in cron.hourly.
    The most tidy solution might be a daemon process. But then I never
    programmed such a thing and I most probably won't got into this just
    for saving a bit of CO_2 on old hardware which will be retired rather
    soon.

    GŁnther

  6. Re: Automatic shutdown

    GŁnther Schwarz wrote:
    > Yes, it is a networked backup where the process is initiated by the
    > backup server via xinetd. So the client has to wait until the server
    > calls. But it is rather well balanced and two hours are plenty for this
    > specific network.


    And unneeded.

    > The proper solution would be to hack the amanda backup software so that
    > the server sets a wol command prior to initiate the backup process on a
    > given client. But I won't go into this as it is simply much to much
    > hazzle and I simply can't see how this could be done easily (same with
    > PCs running server processes like nfs which are up 7/24 because my
    > autofs script has no capability to wake up machines on request).


    You have wake on LAN now, so use that. Have the server use the following
    script
    1) RunWakeOnLan
    2) RunBackup
    3) RunUpdate
    4) RunShutdown

    1 and 2 will be done localy
    3 and 4 will be done via ssh and run on the remote machine and could
    even be one script.

    > I could indeed replace the crontab entry '30 3 * * * root shutdown -h
    > now' with a more sophisticated script taking these and more additional
    > conditions into account. But then I was asking for a simple solutions
    > that does not need much scripting work to be done.


    To me that IS a simple solution. ;-) You want a point-and-click
    solution? That does not excist, as far as I know.
    The advantage of a little bit of scripting is that adding extra machines
    later is very easy and only requires adding the machines name to a list.

    > If the backup fails one night it will most likely complete the next one
    > without problems. So this is not really a concern as long as backups
    > are running nicely most of the time. I check the logs on the backup
    > server on a daily basis, so I'm well aware of was is going on. Also the
    > update script does send an email upon completion.


    The error control in the script is just an added extra, not a necesity.
    I have learned that it comes in handy to at least notify me that
    something went wrong. It does not have to be complete recovery control.
    A simple "Backup failed" message can be easier then reading all the
    output each time.

    And that is obviously up to you, but I would go with one script ran from
    the server that steers all the other machines/ To me that is the easiest
    solution.

    the advantage of doing it vcia an ssh script is that you do not need NFS
    running.

    houghi
    --
    > Knock-knock.
    > Who's there?
    > Under the Patriot Act, we don't have to tell you that.


  7. Re: Automatic shutdown

    houghi wrote:

    > GŁnther Schwarz wrote:
    >> Yes, it is a networked backup where the process is initiated by the
    >> backup server via xinetd. So the client has to wait until the server
    >> calls. But it is rather well balanced and two hours are plenty for
    >> this specific network.

    >
    > And unneeded.


    As I already mentioned in my previous posting it will be hard to do it
    otherwise. The client has to be up and waiting for the server to call.
    See www.amanda.org for details.

    >> The proper solution would be to hack the amanda backup software so
    >> that the server sets a wol command prior to initiate the backup
    >> process on a given client. But I won't go into this as it is simply
    >> much to much hazzle and I simply can't see how this could be done
    >> easily (same with PCs running server processes like nfs which are up
    >> 7/24 because my autofs script has no capability to wake up machines
    >> on request).

    >
    > You have wake on LAN now, so use that. Have the server use the
    > following script
    > 1) RunWakeOnLan
    > 2) RunBackup
    > 3) RunUpdate
    > 4) RunShutdown
    >
    > 1 and 2 will be done localy


    .... on the backup server. This is already implemented and running.

    > 3 and 4 will be done via ssh and run on the remote machine and could
    > even be one script.


    Updates are not initiated by a server in this network. Crond is very
    nice for this. You're right, I could do the two tasks in one script
    which would also take care of not shutting down prior to the update
    job.

    >> I could indeed replace the crontab entry '30 3 * * * root shutdown -h
    >> now' with a more sophisticated script taking these and more
    >> additional conditions into account. But then I was asking for a
    >> simple solutions that does not need much scripting work to be done.

    >
    > To me that IS a simple solution. ;-) You want a point-and-click
    > solution? That does not excist, as far as I know.


    This was my question actually. Not a graphical tool, but many things are
    preconfigured on SuSE systems which are somehow hidden in the
    filesystem. That's also why I asked this question in this group.
    Otherwise it would just a general question on Linux system
    administration and not really on topic for a.o.l.s.

    > And that is obviously up to you, but I would go with one script ran
    > from the server that steers all the other machines/ To me that is the
    > easiest solution.


    I like cfengine for this. It distributes configuration files or scripts
    and controls processes without the need for a central server taking
    care of everything.

    > the advantage of doing it vcia an ssh script is that you do not need
    > NFS running.


    I do not run NFS for system administration. That would not be a good
    idea.

    GŁnther

  8. Re: Automatic shutdown

    GŁnther Schwarz wrote:
    >> And unneeded.

    >
    > As I already mentioned in my previous posting it will be hard to do it
    > otherwise. The client has to be up and waiting for the server to call.


    You said you did a wake on lan. So do the wake on lan, wait and do the
    rest.

    >> 1 and 2 will be done localy

    >
    > ... on the backup server. This is already implemented and running.


    OK, I understand where I was not clear. To me the nackup server is the
    one that I would let it steer all and for me would be 'local'

    > Updates are not initiated by a server in this network.


    And that is something I would do. I would steer it all from one place.
    That makes it easier to maintain.


    houghi
    --
    I do not want life insurance.
    I want all people to be genuinely grieving when I die.

    houghi

  9. Re: Automatic shutdown

    houghi wrote:

    > GŁnther Schwarz wrote:


    >> Updates are not initiated by a server in this network.

    >
    > And that is something I would do. I would steer it all from one place.
    > That makes it easier to maintain.


    See www.cfengine.org on how to do an easy to maintain administration
    from one place and still profit from the capabilities of the clients.
    As for updates this can be easily done by distributing a script
    to /etc/cron.d. No need for a server for this task.
    And to bring this on topic again for a newsgroup on SuSE systems: the
    output of the current implementation of zypper on SuSE 10.3 is
    extremely unpleasant if run by an automatic update script:

    [2K* Installing: mozilla-xulrunner181-1.8.1.12-1.2 [0%] [2K* Installing:
    mozilla-xulrunner181-1.8.1.12-1.2 [100%] [2K* Installing:
    mozilla-xulrunner181-1.8.1.12-1.2 [0%] [2K* Installing:
    mozilla-xulrunner181-1.8.1.12-1.2 [50%] [2K* Installing:
    mozilla-xulrunner181-1.8.1.12-1.2 [0%] [2K* Installing:
    mozilla-xulrunner181-1.8.1.12-1.2 [0%] [2K* Installing:
    mozilla-xulrunner181-1.8.1.12-1.2 [0%] [2K* Installing:

    (Followed by about 100 lines of the same)
    I'm still trying to find out the proper command line option to make the
    output readable when piped to a file. But then I probably complained
    too often here about the various update mechanisms by Novell and SuSE.

    GŁnther

  10. Re: Automatic shutdown

    GŁnther Schwarz wrote:
    > houghi wrote:
    >
    >> GŁnther Schwarz wrote:

    >
    >>> Updates are not initiated by a server in this network.

    >>
    >> And that is something I would do. I would steer it all from one place.
    >> That makes it easier to maintain.

    >
    > See www.cfengine.org on how to do an easy to maintain administration
    > from one place and still profit from the capabilities of the clients.


    I believe SUSE (not openSUSE) had a YaST plugin or the possibilaty to do
    remote updates by push instead of pull. Not sure and I have never tested
    it or looked closer to it and do not even know wether this would be an
    option.

    I just ssh to my machine and do all I need. :-D

    houghi
    --
    I do not want life insurance.
    I want all people to be genuinely grieving when I die.

    houghi

+ Reply to Thread