Page 1 of 4 123 ... LastLast
Results 1 to 10 of 31

Thread: cancel shutdown script help

  1. #1
    Join Date
    Dec 2007
    Location
    green bay, wi
    Beans
    2,162
    Distro
    Lubuntu 14.04 Trusty Tahr

    Lightbulb cancel shutdown script help

    i have a script that runs when i startup

    #!/bin/bash
    echo xxx | sudo -S sudo shutdown -h 19:00

    works fine
    am trying to write a script that will cancel if i want. the below doesnt work

    #!/bin/bash
    echo xxx | sudo -S sudo shutdown -c now

    sure i am overlooking the obvious. any ideas
    tks

  2. #2
    Join Date
    Dec 2007
    Location
    green bay, wi
    Beans
    2,162
    Distro
    Lubuntu 14.04 Trusty Tahr

    Lightbulb Re: cancel shutdown script help

    my bad i am trying to run it in lubuntu not ubuntu

  3. #3
    Join Date
    Dec 2007
    Location
    green bay, wi
    Beans
    2,162
    Distro
    Lubuntu 14.04 Trusty Tahr

    Lightbulb Re: cancel shutdown script help

    if i open a terminal and type sudo shutdown -c and then enter my password it works. sure i have a syntax problem with my script

  4. #4
    Join Date
    Sep 2006
    Beans
    7,016
    Distro
    Lubuntu Development Release

    sudoers

    You can set sudo so that it does not require a password for shutdown.

    Code:
    %rburkartjo ALL=(ALL) NOPASSWD: /sbin/shutdown -h 19:00, /sbin/shutdown -c
    With cancelling a shutdown order with -c, a time is not needed. Any text after the -c will be interpretred as the message.

    You can also specify a pattern instead of "19:00" in sudoers
    Last edited by Lars Noodén; January 10th, 2014 at 08:07 PM. Reason: removed unneeded quotes

  5. #5
    Join Date
    Dec 2007
    Location
    green bay, wi
    Beans
    2,162
    Distro
    Lubuntu 14.04 Trusty Tahr

    Lightbulb Re: cancel shutdown script help

    tks lars

  6. #6
    Join Date
    Dec 2007
    Location
    green bay, wi
    Beans
    2,162
    Distro
    Lubuntu 14.04 Trusty Tahr

    Lightbulb Re: cancel shutdown script help

    okay didnt work. when i added that to line to suders it messed me up. i cant get access to the sudoers file using gksudo nautilus. any idea how to access i need to remove the line from sudoers. tks

    error message

    ray@ray-Latitude-D630:~$ sudo su
    sudo: >>> /etc/sudoers: syntax error near line 27 <<<
    sudo: parse error in /etc/sudoers near line 27
    sudo: no valid sudoers sources found, quitting
    sudo: unable to initialize policy plugin
    ray@ray-Latitude-D630:~$

    tks

  7. #7
    Join Date
    Sep 2006
    Beans
    7,016
    Distro
    Lubuntu Development Release

    Re: cancel shutdown script help

    It's possible to lock yourself out with sudo. I guess since that goes with out saying it went unsaid.

    You can boot in recovery mode and rem out the offending line, as one option.

    In the future, it is a good practice to use visudo to edit sudoers. It won't let you save a broken configuration. By default it uses nano, which is a user-friendly editor.

  8. #8
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: cancel shutdown script help

    There is no need to boot into recovery. You can use pkexec to run a command as another user/root
    Code:
    pkexec visudo

  9. #9
    Join Date
    Sep 2006
    Beans
    7,016
    Distro
    Lubuntu Development Release

    Re: cancel shutdown script help

    Quote Originally Posted by sisco311 View Post
    You can use pkexec to run a command as another user/root
    Cool. That seems to work even with a broken sudoers.

  10. #10
    Join Date
    Sep 2006
    Beans
    7,016
    Distro
    Lubuntu Development Release

    patterns

    Also, sudoers doesn't like a colon (:) so you will have to use a ? instead if you want a pattern for the time.

    Code:
    %rburkartjo  ALL=(ALL) NOPASSWD: /sbin/shutdown -c, /sbin/shutdown -h [0-9][0-9]?[0-9][0-9]
    The method it uses is globbing rather than regex. So a ? stands for any single character.

Page 1 of 4 123 ... LastLast

Tags for this Thread

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
  •