Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: scripts in crontab not executed if computer (Dell desktop, openSUSE 11.2) inactive

  1. #1

    Default scripts in crontab not executed if computer (Dell desktop, openSUSE 11.2) inactive

    I have various scripts intended to retrieve files from the web regularly during day and night. These scripts work fine, and are executed by my crontab table -- but only provided the machine is not in sleep mode. I don't want the computer in active mode 24/7 just so it can do a ten second job four times a day. Is there a solution to this other than to disable the sleep mode under Power Management? Thanks, John.

  2. #2

    Default Re: scripts in crontab not executed if computer (Dell desktop, openSUSE 11.2) inactive

    maybe rtcwake rtcwake(8) €” Linux manual pages part of pm-ttols package
    openSUSE Leap 42.1 x64, Plasma 5 & KDE 4.14.x, pretty current proprietary Nvidia drivers (self-compiled)

  3. #3
    Join Date
    Dec 2010
    Location
    Ankara, Turkey
    Posts
    250

    Default Re: scripts in crontab not executed if computer (Dell desktop, openSUSE 11.2) inactive

    There is script in ubuntu forums that claimed to be executed when system goes into idle. You can find it in here: HOWTO: Run a Program or Windows Screen Saver when System is Idle - Ubuntu Forums

    It seems like it can be modified for your needs. As a command, you what google01103 said. So this is what you will achive,

    When your computer thinks its idle, script executed, telling rtcwake sleep until specified time. When specified time comes, your computer should get up and execute your cron job.

    About specified time, you can write a simple bash file to calculate difference between now and lets say 6:00 am, so that your rtcwake will get your computer up and running exactly when you need it. After waking up, it will stay awake until next screensaver jumps in.
    The only problem with troubleshooting is that sometimes trouble shoots back.
    My blog (in Turkish): http://yasar.serveblog.net

  4. #4

    Default Re: scripts in crontab not executed if computer (Dell desktop, openSUSE 11.2) inactive

    Thanks Google01103 and Yasar11732. I've made some progress with using rtcwake (and using date to supply it with the wanted time to awaken the machine). John.

  5. #5

    Default Re: scripts in crontab not executed if computer (Dell desktop, openSUSE 11.2) inactive

    j1d1w1 you should post your results and script(s) as it's a bit obscure and others might at some point have an interest
    openSUSE Leap 42.1 x64, Plasma 5 & KDE 4.14.x, pretty current proprietary Nvidia drivers (self-compiled)

  6. #6

    Default Re: scripts in crontab not executed if computer (Dell desktop, openSUSE 11.2) inactive

    Thanks for the suggestion google01103, I'll need first to sort out how to do that (there is nothing too fancy about my crontab file though). Would I just literally copy code into this window?

    I've made some progress following the url supplied by Yasar11732. I have figured out how to use rtcwake and use date to supply it with the needed time. I've written (or largely, copied) a perl script that is supposed to set up these commands so that each time the machine goes inactive the needed rtcwake commands are issued. I hoped I might be able to make this active by adding a line to /etc/profile.local, viz. perl /usr/local/sbin/jdw.pl . However when I source /etc/profile.local with that line inserted, I get a syntax error. I have no experience with perl, so that's a place to start, but perhaps there is something more profoundly wrong. I can't follow that link too literally as it applies to Ubuntu. Thx, jdw

  7. #7
    Join Date
    Dec 2010
    Location
    Ankara, Turkey
    Posts
    250

    Default Re: scripts in crontab not executed if computer (Dell desktop, openSUSE 11.2) inactive

    Quote Originally Posted by j1d1w1 View Post
    Thanks for the suggestion google01103, I'll need first to sort out how to do that (there is nothing too fancy about my crontab file though). Would I just literally copy code into this window?

    I've made some progress following the url supplied by Yasar11732. I have figured out how to use rtcwake and use date to supply it with the needed time. I've written (or largely, copied) a perl script that is supposed to set up these commands so that each time the machine goes inactive the needed rtcwake commands are issued. I hoped I might be able to make this active by adding a line to /etc/profile.local, viz. perl /usr/local/sbin/jdw.pl . However when I source /etc/profile.local with that line inserted, I get a syntax error. I have no experience with perl, so that's a place to start, but perhaps there is something more profoundly wrong. I can't follow that link too literally as it applies to Ubuntu. Thx, jdw
    Maybe you can share your scripts here, so that people with perl experience can help you. The thing you will get, at least, more eyes on your codes that migt be reduce the occuring chances of obvious mistakes.
    The only problem with troubleshooting is that sometimes trouble shoots back.
    My blog (in Turkish): http://yasar.serveblog.net

  8. #8

    Default Re: scripts in crontab not executed if computer (Dell desktop, openSUSE 11.2) inactive

    Thanks yasar11732. Below I have copied in the perl script, more or less as copied. Its intent is to make sure the machine is active in time to respect instrcutions in my crontab, which I also copied in below. Thx, jdw

    Code:
    #!/usr/bin/perl
    
    # Latest modification by JDW 21 Mar. 2011 (created 20 Mar. 2011)
    
    # this script copied from HOWTO: Run a Program or Windows Screen Saver when System is Idle - Ubuntu Forums
    # in context of need to find a way to force the Dell machine to execute
    # wget instructions (emerging from sleep mode).
    
    # need to be superuser to create/edit a file in this directory /usr/local/sbin
    
    # The idea is as follows: when the computer goes into sleep mode this
    # script is executed, and orders the machine to sleep until a time I specify
    # These wake times need to be coordinated with the crontab file, and
    # the machine should be woken a minute or so before the timing for the wget
    #
    
    my $cmd = "dbus-monitor --session \"type='signal',interface='org.gnome.ScreenSaver', member='SessionIdleChanged'\"";
    
    open (IN, "$cmd |");
    
    while (<IN>) {
    if (m/^\s+boolean true/) {
    #when Ubuntu idles these commands will run
    system("/usr/sbin/rtcwake -m mem -t $(date --date=01:00:00 +%s")
    system("/usr/sbin/rtcwake -m mem -t $(date --date=05:00:00 +%s")
    system("/usr/sbin/rtcwake -m mem -t $(date --date=10:00:00 +%s")
    system("/usr/sbin/rtcwake -m mem -t $(date --date=15:00:00 +%s")
    #system("COMMAND"); #you can remove or add more commands by
    # adding another system("COMMAND"); line
    } elsif (m/^\s+boolean false/) {
    #when Ubuntu returns from idle these commands will run, delete these two system lines if not wanted/needed
    #system("COMMAND");
    #system("COMMAND");
    system("echo Issued a wake-up reminder to ensure scheduled crontab jobs run");
    }
    }
    Here's part of my crontab file...

    Code:
    # Latest change 20 Mar. 2011
    
    # need to synchronize the wget execution times with my pearl script in /usr/local/sbin (must be su to edit it) which ensures machine is awake in time to see these. Thus I always execute the wget 5 minutes after the hour
    
    # copy of the crontab file on Tornado which runs Red Hat Fedora
    # copied 17 Mar. 2011 to transfer to Dell Linux machine
    
    #14 10 * * * /usr/sbin/rtcwake -h > ~/junk
    
    #MIN HR  DY MNTH DYofWK CMD
    05   01  *  *    *      source ~/weather/downloadscripts/getcmc00Zcharts.sh
    05   05  *  *    *      source ~/weather/downloadscripts/getcmc06Zcharts.sh
    05   10  *  *    *      source ~/weather/downloadscripts/getcmc12Zcharts.sh
    05   15  *  *    *      source ~/weather/downloadscripts/getcmc18Zcharts.sh
    And here is script getcmc06Zcharts.sh

    Code:
    # latest modification 17 Mar./2011
    #
    #jdw Mar 15,2005 ... retrieving weather analysis files ... sourced at 0900 LST daily
    #
    cd ~/weather/2011/cmc/sfc
    wget http://www.weatheroffice.gc.ca/data/analysis/jac06_100.gif
    /usr/bin/convert jac06_100.gif sfc_$(date +%Y%m%d)@06Z.png
    rm jac06_100.gif
    #
    cd ~/weather/downloadscripts

  9. #9
    Join Date
    Dec 2010
    Location
    Ankara, Turkey
    Posts
    250

    Default Re: scripts in crontab not executed if computer (Dell desktop, openSUSE 11.2) inactive

    Code:
    system("/usr/sbin/rtcwake -m mem -t $(date --date=01:00:00 +%s")
    Change all of these lines to

    Code:
    system("/usr/sbin/rtcwake -m mem -t $(date --date=01:00:00 +%s)")
    You are forgetting to close the brackets you opened for date command.
    The only problem with troubleshooting is that sometimes trouble shoots back.
    My blog (in Turkish): http://yasar.serveblog.net

  10. #10

    Default Re: scripts in crontab not executed if computer (Dell desktop, openSUSE 11.2) inactive

    Thanks yasar11732... done that (and added semi-colon at end of each of those lines). Now when I source /etc/profile.local (which contains the line perl -w /usr/local/sbin/jdw.pl ) there is no error message, but the terminal goes into some weird mode. If the crontab instructions are executed tonight I'll know its working!

Page 1 of 2 12 LastLast

Posting Permissions

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