Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Hey I had the same problem, I built a Cocoa solution using the IOPowerManager interface, dailyWakeup. When periodic daily then runs I have it requeue a request for the next day. I also wrote a GUI interface to the timer queue ( Cocoa based). My main problem is that when I wake the box up, it won't stay awake very long, just three or four minutes even though the energy saver panel is set for 15 minutes. Details at: http://homepage.mac.com/levanj/Cocoa --Jerry
    • Yes, I just saw that yesterday. I was going to ask you if you know why I would have something scheduled for wakeup, that sometimes it won't wake up at all.
      • If you look at the system log, I bet it will show the wakeup did take place, it probably went back to sleep before the task fired. I find that I have to fiddle a bit to get the wakeup close enought to task time. Cron only checks one a minute... Jerry
        • No, I had the wakeup scheduled hours before it went to sleep, then it went to sleep, and it never woke up hours later, when it was scheduled to.
          • This morning I had a wakeup scheduled for about 3:13:45 am
            this was in my system log.
            Apr 27 03:15:02 macjerry syslogd: restart
            Apr 27 03:15:03 macjerry kernel: ApplePMUUserClient::setProperties AutoWake 0x00000000
            Apr 27 03:15:03 macjerry kernel: ApplePMUUserClient::setProperties AutoPower 0x00000000
            Apr 27 03:15:03 macjerry kernel: ApplePMUUserClient::setProperties AutoWake 0x00015123
            Apr 27 03:15:03 macjerry osascript: LaunchApplication(/System/Library/CoreServices/System Events.app)
            Apr 27 03:15:59 macjerry /usr/libexec/fix_prebinding: fix_prebinding quitting for now.
            Apr 27 03:17:23 macjerry mDNSResponder[147]: mDNSResponder Sleeping at 567782354
            Apr 27 03:17:24 macjerry kernel: ApplePMUUserClient::setProperties AutoWake 0x00015096
            Apr 27 03:17:28 macjerry kernel: AppleNMI mask NMI
            Apr 27 03:17:28 macjerry configd[92]: AppleTalk shutdown
            Apr 27 03:17:28 macjerry configd[92]: AppleTalk shutdown complete
            Apr 27 07:38:29 macjerry kernel: System Sleep

            Note it went back to sleep after only four minutes even though
            the Energy saver is set for 15 minutes. The autowake setting
            referred to above is about 24 hours and is emplaced by my
            cron job calling "dailyWakeup". Did you check the system log?
            I think the Power Manager might still be a bit flakey.

            My PMQueueManager shows the queue....

            Jerry
            • I'll get back to you hopefully tomorrow ... I am setting it to wake up at 2:55 a.m. tomorrow. My cron job runs every 15 minutes to set it.
              [pudge@thornton pudge]$ date; pmset -g sched
              Tue Apr 27 19:27:03 PDT 2004
              No scheduled events.
              [pudge@thornton pudge]$ date; pmset -g sched
              Tue Apr 27 19:35:39 PDT 2004
              Scheduled power events:
                wake at 4/28/2004 2:55:00AM by wake.plx
            • Apr 28 02:55:08 localhost kernel: System Sleep
              Apr 28 02:55:08 localhost kernel: System Wake
              Apr 28 02:55:08 localhost kernel: Wake event 0040
              Apr 28 02:55:09 localhost kernel: AppleNMI unmask NMI
              Apr 28 02:55:09 localhost kernel: ^PAirPort:  Link UP:  "PudgeLAN" - xxxxxxx - chan 10
              Apr 28 02:55:12 localhost mDNSResponder[174]: mDNSResponder Waking at 3704028
              Apr 28 02:55:12 localhost kernel: ApplePMUUserClient::setProperties AutoWake 0x00000000
              Apr 28 02:55:12 localhost kernel: ApplePMUUserClient::setP

              • Nope, I never thought about it :) I suspect each keydown, mousemotion probably sets a watchdog timer, since nothing gets moved/pressed it is not clear to me what would happen... Jerry
                • Yeah, if I get some time, I may try to see if I can't reset that timer.
                  • Hmm,
                    Let's try a photosensor looking at the screen, when activated
                    by the wakeup, cut current to electromagnet holding weight
                    above keyboard, yeah that ought to do the trick :)

                    I have not tried (at any time) system events, do you think
                    simulating a key press would do the trick?

                    Jerry
                    • I dunno. My first attempt was going to be to look for the timer itself, to reset it. My next was going to be to try simulating it as you mentioned.
                    • Got this from someone at apple... // cc -o keypress keypress.c -framework Carbon
                      #include
                      main() {
                              UpdateSystemActivity(OverallAct);
                              return 0;
                      }

                      He said it "might" work.

                      I got my full fifteen minutes last night...

                      Jerry
                    • Whoops, the include did not include...

                      // cc -o keypress keypress.c -framework Carbon
                      #include <Carbon/Carbon.h>
                      main() {
                          UpdateSystemActivity(OverallAct);
                          return 0;
                      }

                      Jerry
                    • This is with using it, you got your full 15? Excellent. Last night I got nothing:

                      Apr 29 02:55:09 localhost kernel: AppleNMI mask NMI
                      Apr 29 02:55:09 localhost kernel: AirPort:  Link DOWN
                      Apr 29 02:55:10 localhost kernel: System Sleep
                      Apr 29 02:55:10 localhost kernel: System Wake
                      Apr 29 02:55:10 localhost kernel: Wake event 0040
                      Apr 29 02:55:10 localhost kernel: AppleNMI unmask NMI
                      Apr 29 02:55:10 localhost kernel: ^PAirPort:  Link UP:  "PudgeLAN" - xxxxxxx - chan 10
                      Apr 29 02:55:13 localhost kern

                    • He also told me that there was a problem if you use a password
                      protected screensaver, if a password is not entered in 90 seconds, the machine will go back to sleep.

                      Jerry
                    • I don't use a screen saver.

                      But how do I get that entered when the machine wakes up?
                    • You can have cron execute it :) Last night I added one line
                      to my /etc/daily.local file. This gets executed by /etc/daily
                      which is in turn executed by periodic .
                      /usr/bin/mail -s Crontab jerry <<DOC
                      Cron ran at `date`
                      `/usr/local/bin/dailyWakeup`
                      `/usr/local/bin/keypress`
                      DOC

                      dailyWak eup queues a request for the following night, the
                      keypress code evidently extends the session.

                      Tonight I am going to create a 400.mystuff file that simply
                      executes the /usr/local/bin/keypress command and dump
                      it into /etc/periodic
                    • Putting it in /etc/daily.local will guarantee it is run before the computer goes back to sleep? It looks to me (from looking at daily.out) that stuff from daily won't run unless the computer is awake at the time.
                    • On my system, daily.local always fires, I guess that I don't
                      have that much extra to do...

                      However I am starting to do weekly backups of some big
                      folders and that is why I am going to have a seperate file
                      containing code that will execute the keypress function and
                      have periodic execute this file just before any of the longer
                      jobs...Are we on the same page?

                      dailyWakeup queues an event that causes the system to wake
                      a little before cron fires.

                      cron fires and executes a script that contains the keypress function. (
                    • dailyWakeup queues an event that causes the system to wake a little before cron fires.

                      That's the part that concerns me. Last night, the machine wasn't even awake long enough for the clock in the GUI to update. I guess I can try setting them a minute apart and see what happens.
                    • I just added this to my perl script instead of making it a separate program, fwiw. And I tried it, and it woke the screen up after it had gone to sleep, so that's a good sign. :-)
                    • I created 400.keypress containing:
                      #!/bin/sh
                      /usr/local/bin/keypress

                      and dumped it into
                      /etc/periodic/{daily | weekly | daily} ( and made sure it is executable )

                      It fired first when cron started and I got my 15 minutes of fame.

                      http://homepage.mac.com/Cocoa for the whole story/package

                      Jerry
                    • Last night the machine stayed awake for awhile, but then Backup.app didn't run at 3 a.m. like it was supposed to. Grrrr! Maybe I'll try waking it up earlier than 2:55 a.m.