Professional Web Applications Themes

shuting down via script - Sun Solaris

HI all I have just replaced a linux "server" with a solaris 9 server (running on a sunblade 100) on that linux server I had a script that checked weather a file was present and if not it shut the system down to a complete halt. All this with the help of cron. I include the scripts. Now to my question. What modifications do I need to do to the script as well as to the crontabs? **** First script (shutdown.sh)*** #!/bin/bash cp /etc/crontab /home/cronbackup/crontab.$$ cp /etc/cronbackup/cron.shutdown /etc/crontab ********** with this crontab: ******* SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # run-parts 01 ...

  1. #1

    Default shuting down via script

    HI all
    I have just replaced a linux "server" with a solaris 9 server
    (running on a sunblade 100) on that linux server I had a script that
    checked weather a file was present and if not it shut the system down
    to a complete halt. All this with the help of cron. I include the
    scripts.
    Now to my question. What modifications do I need to do to the script
    as well as to the crontabs?

    **** First script (shutdown.sh)***
    #!/bin/bash
    cp /etc/crontab /home/cronbackup/crontab.$$
    cp /etc/cronbackup/cron.shutdown /etc/crontab
    **********
    with this crontab:
    *******

    SHELL=/bin/bash
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    MAILTO=root
    HOME=/

    # run-parts
    01 * * * * root run-parts /etc/cron.hourly
    02 4 * * * root run-parts /etc/cron.daily
    22 4 * * 0 root run-parts /etc/cron.weekly
    42 4 1 * * root run-parts /etc/cron.monthly
    00 23 * * * root /home/cronbackup/shutdown.sh

    **********************
    next script (shutdown2.sh)
    *****************
    #!/bin/bash
    dfile=/home/Daniel/noshutdown.txt
    bfile=/home/Sherman/noshutdown.txt
    if [ -f $dfile ]; then
    exit 1
    fi
    if [ -f $bfile ]; then
    exit 1
    fi
    cp /etc/crontab /home/cronbackup/crontab.$$
    cp /etc/cronbackup/cron.real /etc/crontab
    shutdown -h now
    ***************
    with this crontab
    *******
    SHELL=/bin/bash
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    MAILTO=root
    HOME=/

    # run-parts
    01 * * * * root run-parts /etc/cron.hourly
    02 4 * * * root run-parts /etc/cron.daily
    22 4 * * 0 root run-parts /etc/cron.weekly
    42 4 1 * * root run-parts /etc/cron.monthly
    */10 * * * * root /home/cronbackup/shutdown2.sh


    any help would be appriciated. Also the hourly, daily, weekly, monthly
    things in the crontba is just from the installation, so I don't worry
    about them, the important bit is my-script :-)

    I have got the impression from man pages that "poweroff" doesn't
    really do a neat job at shutting down the computer.

    /daniel
    Daniel Guest

  2. #2

    Default Re: shuting down via script


    Hi all,
    Hi Daniel,


    Daniel wrote: 

    To shutdown a Solaris box and then power off use "init 5" as root.
    Here is my suggestion for your script:

    #!/bin/bash

    dfile=/home/Daniel/noshutdown.txt
    bfile=/home/Sherman/noshutdown.txt

    [ -f $dfile -o -f $bfile ] && exit 1

    cp /etc/crontab /home/cronbackup/crontab.$$
    cp /etc/cronbackup/cron.real /etc/crontab

    init 5


    Greetings,
    Ralf.

    Ralf Guest

  3. #3

    Default Re: shuting down via script

    Hi again.
    I looked at your suggestion Ralf, and it makes sense. But there are
    one thing I'm still confused about, and that is the crontabs. Are they
    infact stored in /etc/crontab? because I don't have that file on my
    system.
    Also is the syntax identical to the one I have? (again, I only worry
    about the last line)
    Thanks for the input!

    /daniel

     
    >
    >To shutdown a Solaris box and then power off use "init 5" as root.
    >Here is my suggestion for your script:
    >
    >#!/bin/bash
    >
    >dfile=/home/Daniel/noshutdown.txt
    >bfile=/home/Sherman/noshutdown.txt
    >
    >[ -f $dfile -o -f $bfile ] && exit 1
    >
    >cp /etc/crontab /home/cronbackup/crontab.$$
    >cp /etc/cronbackup/cron.real /etc/crontab
    >
    >init 5
    >
    >
    >Greetings,
    >Ralf.
    >[/ref]

    Daniel Guest

  4. #4

    Default Re: shuting down via script

    Hi Daniel,

    the crontabs are in /var/spool/cron/crontabs/<username>. The syntax is
    exactly similar.

    There is no "system"-crontab as /etc/crontab in Linux or *BSD.

    Greetings

    Ralf.


    Daniel wrote: 
    >>
    >>To shutdown a Solaris box and then power off use "init 5" as root.
    >>Here is my suggestion for your script:
    >>
    >>#!/bin/bash
    >>
    >>dfile=/home/Daniel/noshutdown.txt
    >>bfile=/home/Sherman/noshutdown.txt
    >>
    >>[ -f $dfile -o -f $bfile ] && exit 1
    >>
    >>cp /etc/crontab /home/cronbackup/crontab.$$
    >>cp /etc/cronbackup/cron.real /etc/crontab
    >>
    >>init 5
    >>
    >>
    >>Greetings,
    >>Ralf.
    >>[/ref]
    >
    >[/ref]

    --

    Mit freundlichem Gruß / Kind regards

    Ralf Bensmann

    --
    1[wan]Ci - Ralf Bensmann, Geschäftsführer
    Gessellschaft für interaktive Kommunikations- und Informationsmedien mbH
    Heisstr. 51 - 48145 Münster - Germany - mailto:de
    phone +49 251 52092-0 - fax +49 251 52092-100 - http://www.1ci.de
    phone +49 179 7415447

    Solution Partner T-Systems PCM GmbH, Workgroup Solution Reseller Sun
    Microsystems, Fujitsu Siemens Global Alliance Partner, Oracle Partner
    Program Member

    http://www.branchenloesungen.de - http://www.used-sun.de

    Ralf Guest

Similar Threads

  1. Illustrator 10 shuting down when moving objects from one layer to another!
    By trishp@adobeforums.com in forum Adobe Illustrator Windows
    Replies: 1
    Last Post: June 7th, 08:15 AM
  2. Replies: 2
    Last Post: January 24th, 06:00 AM
  3. computer automatically shuting down
    By shalonda in forum Windows Setup, Administration & Security
    Replies: 2
    Last Post: August 13th, 07:23 AM
  4. Some one is logging in to my PC as Anonymous and Shuting me down
    By Chad in forum Windows Setup, Administration & Security
    Replies: 1
    Last Post: July 9th, 03:18 AM
  5. Execute shell script from a perl script
    By kderaedt in forum Perl / CGI
    Replies: 3
    Last Post: June 26th, 08:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139