How do I run an Apple Script only when the computer is awake at the specified time and NOT upon waking after the specified time?

I've been using Steve Lambert's SelfControl to block myself from certain time-sucking internet sites for a certain period of time every day. I've automated the program launch using an AppleScript that runs based on an iCal alarm, but the problem is that if my computer has been asleep or shut off, the script will run as soon as I wake it up or start it up, and that can be very inconvenient if I'm intending to use my computer not during the hours when I intended to restrict access to such websites.
So, is there any way to schedule an AppleScript to run *only* if the computer is running at the designated time and not upon waking/starting up after the alarm has passed if the computer was asleep/off?
I started investigating launchd, as I understand this is the successor to cron/crontab in OS X Lion, but it appears that launchd has the same behavior I dislike in the iCal alarm approach--the script will run upon waking even if the time when it was supposed to run has already passed...unless there is a way to change this behavior?

The obvious/easy solution would be to add some logic to the script to see what the time is.
If you expect the script to run at, say, 1pm, but the script checks the time and sees that it's 5pm then you can assume the machine was asleep at the time and thefore you can bail out gracefully.
if (hours of (get current date)) = 13 then
  -- it's sometime in the 1pm hour...
end if
You can fine-tune the check as much as you like

Similar Messages

  • How do I let lightroom show the actrual number of files in a map and not a number including the total of all submaps?

    How do I let lightroom show the actrual number of files in a map and not a number including the total of all submaps?

    If by "map" you mean directory or folder, in the Library menu there is a toggle for "show photos in subfolders".

  • How can I run a SQL script file...

    How can I run a SQL script file from a location on my computer without providing the whole path?
    Is there some way I can set a "Working folder" in SQL Plus??
    Thanks!
    Tom

    You can create an environment variable called "SQLPATH" which is a list of directories that SQL*Plus will search for your .SQL
    scripts.
    I would like to use another directory than the oracle/bin...
    How can I do this ??
    Hello,
    U can do this by this way:
    Save odm_script.sql file to the default Oracle
    directory i.e. Oracle-Home/bin and Run following command
    through SQL Plus.
    SQL>@Script_Name
    I hope this will resolve ur problem.
    Regards,
    Omer Saeed Khan.

  • How do I run a vb script in Windows Server 2008 R2

    Hello,
    How do I run a vb script
    to generate an OID to create a new element
    of a schema in an active directory
     in Windows Server 2008 R2?
    Thank you for your feedback.
    Juan Carlos
    Juan Carlos

    Hello,
    How do I run a vb script
    to generate an OID to create a new element
    of a schema in an active directory
     in Windows Server 2008 R2?
    Thank you for your feedback.
    Do you have the script yourself? Assuming yes, it is the command:
    cscript YourScript.vbs
    Mahdi Tehrani   |  
      |  
    www.mahditehrani.ir
    Please click on Propose As Answer or to mark this post as
    and helpful for other people.
    This posting is provided AS-IS with no warranties, and confers no rights.
    How to query members of 'Local Administrators' group in all computers?

  • How do I run Extended Apple Hardware Test imac 21.5 mid-2010 mavericks

    How do I run Extended Apple Hardware Test imac 21.5 mid-2010 mavericks?  I have tried to start my computer holding down the "D" key but my iMac simply just restarts as normal.
    I have checked the list of iMacs that can be upgraded to do an internet Extended Apple Hardware Test and I do not have one of those computers.
    I cannot find any solution as yet.
    I do not have the start up disks or the usb disks.

    You can't run the hardware test without the installation discs.
    Runaway applications can shorten battery runtime, affect performance, and increase heat and fan activity

  • Running an apple script from excel

    I have been trying to find some visual basic code to run an apple script from an excel workbook for weeks now, but after searching everehwere online and asking in multiple excel forums I have yet to find an answer. It appears it should be possible (as windows users of excel are able to do it, although running different files not apple scripts), but I cant get it to work on a mac, and I have not been able to come accross someone that is running excel on OSX that has an answer. Hoping I can find some mac excel users with apple script and visual basic knowledge here that might have an answer.
    This is a link to the question I posted on excel forum a couple of weeks ago:
    http://www.excelforum.com/excel-programming-vba-macros/962375-vb-code-to-run-a-f ile-on-mac.html

    I use http://macchampion.com/scenario_features.shtml
    dual-core G5/2.3   Mac OS X (10.4.6)   dual screens

  • How can I log into my new (used) Ipad if the previous owner has the only log in information?  I purchased it through Glyde and have no information on the seller.

    How can I activate my new (used) Ipad if the previous owner has the only log in information?  I purchased it through Glyde and have no information on the seller.

    What you've run into is the activation lock. Previous owners are supposed to wipe their devices, and to do that they have to enter their apple ID's. If yours wasn't wiped then it was a careless owner, or the dark side is that whomever sold it, it wasn't theirs to sell.
    Regardless, what Deggie says is your only recourse. Get your money back or own an unusable brick.

  • I tried updating my iPod touch 4th gen and now the screen is bright blue or flashing white and black lines.ive tried the whole home and power button thing but it only brings up the apple icons then goes back to the blue or other screen.please help?

    I tried updating my iPod touch 4th gen and now the screen is bright blue or flashing white and black lines.ive tried the whole home and power button thing but it only brings up the apple icons then goes back to the blue or other screen.please help?

    This has worked for some others.
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try on another computer
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar       

  • I am sharing a apple id acount with my family but when i synced my phone to the computer it erased all of my imformation and put the other phone's imformation on it. I was wondering how I can prevent this from happening?

    I am sharing a apple id acount with my family but when I synced my iphone to the computer it erased all of my imformation and put the other phone's imformation on it. I was wondering how I can prevent this from happening?

    If the ringtones are on the old device just plug it in and do a transfer of purchases then they will be on the computer to sync to the new device.

  • I have Firefox 6.0 running under Windows XL. When I forward an email with a URL in it, my recipients tell me the URL is not highlighted and they have to cut and paste it into their browser. Why? How can I get my forwarded URLs to be highlighted?

    I have Firefox 6.0 running under Windows XL. When I forward an email with a URL in it, my recipients tell me the URL is not highlighted and they have to cut and paste it into their browser. Why? How can I get my forwarded URLs to be highlighted?

    If you think getting your web pages to appear OK in all the major browsers is tricky then dealing with email clients is way worse. There are so many of them.
    If you want to bulk email yourself, there are apps for it and their templates will work in most cases...
    http://www.iwebformusicians.com/Website-Email-Marketing/EBlast.html
    This one will create the form, database and send out the emails...
    http://www.iwebformusicians.com/Website-Email-Marketing/MailShoot.html
    The alternative is to use a marketing service if your business can justify the cost. Their templates are tested in all the common email clients...
    http://www.iwebformusicians.com/Website-Email-Marketing/Email-Marketing-Service. html
    "I may receive some form of compensation, financial or otherwise, from my recommendation or link."

  • How can I watch a Disney movie from the Disney website I have purchased movie cd and I can go to the website on by gateway computer but can't get it to play on my iPad it wants me to download flash but apple doesn't support flash or I can down loadQuickTi

    How can I watch a Disney movie from the Disney website I have purchased movie cd and I can go to the website on by gateway computer but can't get it to play on my iPad it wants me to download flash but apple doesn't support flash or I can down loadQuickTime but don't know how. Says to email website did that but takes me back to same place to email help

    Contact iTunes Customer Support, but honestly, there are no returns for iTunes purchases.

  • HT5631 how do I verify my apple id? I can't sign in to it in mail and I can't make a new one because it just will not process I'm trying to set up iCloud between iPad and iPhone and having ALOT of difficulty pleAse help need it done by later on today!!!!!

    how do I verify my apple id? I can't sign in to it in mail and I can't make a new one because it just will not process I'm trying to set up iCloud between iPad and iPhone and having ALOT of difficulty pleAse help need it done by later on today!!!!!

    In order to use your Apple ID to create an iCloud account, the primary email address associated with the ID must first be verified.  To do this, Apple will send a verification email to your account and you must respond to the email by clicking the Verify Now link.  Make sure you are check the spam/junk folder as well as the inbox.  If it isn't there, go to https://appleid.apple.com, click Manage your Apple ID, sign in, click on Name, ID and Email addresses on the left, then to the right click Resend under your Primary Email Address to resend the verification email.

  • TS1702 My iMessage is only allowing me to select messages to be sent and received from my email. If my number is an option, but it will not let me select my number, how do I get the iMessages to be sent to my number and not my email?

    My iMessage is only allowing me to select messages to be sent and received from my email. If my number is an option, but it will not let me select my number, how do I get the iMessages to be sent to my number and not my email?

    Try ejecting your iphone from iTunes and then close iTunes. Now retry. Hope this helps.

  • HT204053 how come there is another apple id appears when im about to update the applications that i have downloaded?

    how come there is another apple id appears when im about to update the applications that i have downloaded?

    When a stranger's Apple ID appears on your Mac in conjunction with an update for an app that you have never installed, you have a pirated app on your Mac. The pirated app is not the app calling for the update. This pirated app has been cracked with the MAS receipt from usually a free app, often Angry Birds or Twitter, acquired by the person whose Apple ID you see.
    You may not have realized that it was a pirated app when you installed it. You may have believed that it was a trail version or a "free" version.
    All MAS apps have a MAS receipt in their app bundle. Check any app acquired from the MAS. Right click on the app's icon in your Apps folder and choose Show package contents. In the Contents folder is a _MASReceipt folder and in that folder is the coded MAS receipt. It has the Apple ID of the MAS account that bought/acquired the app from the MAS. It is that receipt that the MAS uses to alert you that an app has an update. There would not be a notice of an update with someone else's Apple ID showing in the MAS on your Mac, if there was not an app with a receipt from this person's account somewhere on your Mac.
    Download the free app FindAnyFile (FAF);
    http://apps.tempel.org/FindAnyFile/
    This app is easier to use and seems to be more powerful than Spotlight. Open FAF and in the box type _MASReceipt and press Find. It should come up with a list of every app on the Mac with a MAS receipt. Compare the apps with receipts in FAF's list with your purchased apps list in the Mac App Store. The odd app out should be the pirated app.

  • One of my imported MOV files turns "black" after editing with it for a time and I can't retrieve the images. This has happened three times, only this file. The placeholder is still there. Files are fine on hard drive. What gives? how to stop this?

    One of my imported MOV files turns "black" after editing with it for a time and I can't retrieve the images. This has happened three times, only this file. The placeholder is still there. Files are fine on hard drive. What gives? how to stop this? is in final cut pro 10.1.4

Maybe you are looking for

  • How do I get music onto my i pod nano 7th gen

    I am going out of my mind.  I purchased over 200 songs via itunes and can not get them on to my i pod nano 7th gen no matter what ai try--- All my music is also srored in my i cloud--- Does any one know how to move it from the i cloud to the 7th gen

  • Thin white lines showing around shapes

    When I open a logo created in Illustrator in other programs such as acrobat or photoshop there are thin white lines showing around every object! Even on the inside of the surronding lines of an area colored using the live paint bucket (black area sur

  • Installation of labview 2014 SP1 (32 bit)

    Trying to install labview and when I open labview it immediately crashes after about 5 seconds and a crash report pops out with the below message: Exception: Access violation (0xC0000005) at EIP=0x04FDBC56 Version: 14.01.1 (32-bit) Report ID: cee51a3

  • No Adobe Form Is Assigned to the Scenario:  - PCR

    Hi, In my project, configured 5 Custom PCRs as copy of standard PCR and enhace it. When Full authorization USer ids, am able to execute the all PCR-Adobe form and complete the process. When i logo to portal with Z role authorization (with respect to

  • Scenarios for general ledger accounting

    Hello, Is there additional scenarios to assign in FI apart from the following ones : FIN CCA/FIN CONS/FIN PCA/FIN SEGM/FIN_UKV/FIN GSBER as I am looking  into retrieving from FAGLFLEXT the transaction type (RMVCT) and plant fields (WERKS) which I alr