Running Applescript using cron jobs not working

I'm new to conjobs and applescript but I have the script done correctly i believe. (any critique is welcome) I don't want to bloat my calendar with events to do this because I use my calendar for appointments and I don't need the bloat.
Here's my goal: run an apple script at 9am/5pm to enable/disable a mail account (after this works I'm going to add loging in/out of an Messenger account, first things first)
here's my script:
tell application "Mail"
          set offTime to 17
          set onTime to 9
          set dayOfWeek to weekday of (current date)
          set theHour to get the (hours of (current date)) as string
          if theHour ≥ onTime then
                    say "email on"
                    set enabled of account "MAILBOX" to true
          else if theHour ≥ offTime or (dayOfWeek = Saturday or dayOfWeek = Sunday) then
                    say "email Off"
                    set enabled of account "MAILBOX" to false
          end if
end tell
accessing cron jobs via this
sudo pico /etc/crontab 
and within cron jobs i've used
0 9 * * * username osacript
"/Documents/disablemail.scpt"
0 17 * * * username osacript
"/Documents/disablemail.scpt"
variations I've attempted (based on search engine results)
0 9 * * * username osacript
"~/Documents/disablemail.scpt"
0 9 * * * /Documents/disablemail.scpt
0 9 * * * ~/Documents/disablemail.scpt
0 9 * * * osacript /Documents/disablemail.scpt
0 9 * * * osacript ~/Documents/disablemail.scpt
I think that's all of them.
Any feedback/assitance appreciated, thanks!

What's the problem, is the cronjob not getting called at all or is the script giving errors?
One problem you have right off is the cron job you have set up is running as root not as you.

Similar Messages

  • EJB Persistence using cron job

    We have a EJB based bean managed persistence classes that run on the app server. I want to use same classes using cron job.
    How do I do that???
    Tried to execute these classes thru following steps...
    In side stand alone java class - main method create instance of the pmf and get persistence manager.
    Start a tread and call JDO object using persistence manager.
    getting whole bunch or errors like system-server-config.xml file not found. I am not able to create InitialContext outside app server.
    Please give your suggestions. TIA

    Why don't you use a J2EE based scheduler?
    http://java-source.net/open-source/job-schedulers/quartz
    http://java-source.net/open-source/job-schedulers/jcrontab

  • TS1362 I have a Mac Pro tower, am running osx and iTunes will not work.. It basically just stopped working after having run faultlessly for...years... I can see all the songs, playlists etc, but the progress bar will not progress..it's 'stuck'. Suggestion

    I have a Mac Pro tower am running OSX and iTunes will not work. It has always worked flawlessly. I can see all my iTunes content- my playlists, my songs et cetera, But I cannot play anything. The progress bar is  'stuck'...any suggestions?

    Thanks. I have been using iTunes since its inception and have never had a problem...I'm using the latest version. The progress bar is the bar that moves when you're playing a song..it just won't start when I double click on a song,..have tried quitting, rebooting etc but nothing works. Apple are useless-they have told me twice they've tried to call me 'momentarily', but I've been waiting by the phone, and they definitely have not tried to call...

  • I have a 2010 Macbook Pro and am a very new user to Mac community. My Mac is just hanging and I am unable to shut it down or do anything at all.  I left it for 2.5 days hoping the battery will run flat but it is not working. Pls help! I am desperate. Tx

    I have a 2010 Macbook Pro and am a very new user to Mac community only started to use this PC a few weeks ago.
    My Mac is just hanging and I am unable to shut it down or do anything at all.  I left it for 2.5 days hoping the battery will run flat but it is not working. Pls help! I am desperate. Tx

    In order to resolve the issue if it occurs again, more info would be helpful as to what occurred prior to the "hang." One potential fix would be to try a Safe Boot:
    After the Mac is completely shut down, push the power button and immediately after the startup tone, hold down the Shift key. The Shift key should be held as soon as possible after the startup tone but not before.
    Release the Shift key when you see the gray Apple icon and the progress indicator (looks like a spinning gear).
    There should be a message that says "SafeBoot." After the Mac is completely booted, try restarting and see if the issue is gone.

  • After installing iPhone Configutilities in my Mac, Personal Hotspot using USB is not working! Please help, I am using 10.7 Lion OS

    After installing iPhone Configutilities in my Mac, Personal Hotspot using USB is not working! Please help, I am using 10.7 Lion OS

    Did you talk to your carrier?

  • I have a late 2008 Macbook Pro, I am trying to run MW3 but it will not work without crashing a few minuets into the game. The general specs on my computer are a dual processor 2.53 ghz. 4 gb ram and a NVIDIA geforce 9400 (9600 is the alternate card)

    I have a late 2008 Macbook Pro, I am trying to run MW3 but it will not work without crashing a few minuets into the game. The general specs on my computer are a dual processor 2.53 ghz. 4 gb ram and a NVIDIA geforce 9400 (9600 is the alternate card).
    Things to note:
    I have been unable to update firmware on this computer for about a year now. Im not sure why.
    I am running a bootleg copy of Windows XP on this computer, I would not like to spend $149 to get Windows 7 if possible.
    any thoughts on the matter would be greatly appreciated, thank you.

    Why don't you take your 'old' MBP into your local Apple Store and have them check out everything that's wrong with it - and I mean everything? Then, when you get an estimate about how much it would cost to get the machine completely repaired, ask about the Apple flat-rate repair pricing?
    It's worth a shot - and with what you may save, you can put in the bank for a new MBP.
    Clinton

  • Database Scheduled Jobs not working

    Hai All,
    In my database Scheduled database jobs not working , but it work manullay fine...
    All parameter are correct including job_queue_processes.. Where I can start troubleshoot for this problem.
    Oracle: Oracle 9.2.0.1.0
    Platform : AIX
    Please help ...
    Shiju

    did you enabled the job?Unlikely. DBMS_SCHEDULER was a 10g innovation and as the OP mentioned, they're on 9i.
    Oracle: Oracle 9.2.0.1.0Cheers, APC

  • I have a macbook pro the fan wont stop running the keyboard light is not working and the it wont charge all happened all of a sudden what to do please.

    have a macbook pro the fan wont stop running the keyboard light is not working and the it wont charge all happened all of a sudden what to do please.

    Reset SMC.     http://support.apple.com/kb/HT3964
    Choose the method for:
    "Resetting SMC on portables with a battery you should not remove on your own".
    If this does not help, you may have to take the MBP to the Apple Store  to have it checked.
    Best

  • Cron job : how to run scripts as cron job

    Hi friend,
    Sorry one very small question ..
    Can someone tell me how can i run scripts as cron job .. on HP UX.
    thanks
    ashish

    Hi Ashish,
    open one telnet session.
    crontab -e
    then give the periodicity day and time
    like below
    05 00 * * 1-6  /usr/local/bin/database_backup.sh
    and now create the script file with the command or script to execute.
    Regards
    Ashok Dalai

  • Windows Server 2012 - Printing using UNC path not working

    Hi,
    I have a problem printing using the printer's UNC path ("\\Server_Name\Printer_Hostname") to work with a web
    app hosted on IIS 8. With a windows forms application the UNC path is working fine and the app prints.
    With
    the web app I receive an error "The data area passed to a system call is tool small". 
    Also,
    in the event viewer under Applications and Services Logs -> Microsoft -> PrintService -> Operational, I receive the error "The print spooler failed to reopen an existing printer connection because it could not read the configuration information
    from the registry key S-1-5-82-1980832875-2702362896-1795126167-3622310632-1152289074\Printers\Connections. The print spooler could not open the registry key. This can occur if the registry key is corrupt or missing, or if the registry recently became unavailable."

    I have contacted IIS forum support.
    Please review the link: http://forums.iis.net/p/1213109/2079229.aspx?Re+Windows+Server+2012+Printing+using+UNC+path+not+working
    Their final response:
    Printing from ASP.NET using System.Drawing.Printing itself is a horrible approach, as this namespace was designed for Windows Forms only. The designers did not take everything about ASP.NET in mind, so any issue can happen. That can answer why the HP model
    works while the Samsung fails, as the HP one just "happens
    to work",
    http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx
    Similarly, System.Printing was designed just for WPF.
    About which printing API to use in ASP.NET/IIS, there is no clear answer so far. Thus, your only resource is Microsoft support, who can perform further analysis (with their dedicate utilities and of course Windows source code) and might come across a solution
    to help you out. This is not a trivial scenario.

  • Where used list is not working for IMG nodes/Document   in solar01

    hi experts
    In template project , we are using same IMG objects in different business processes and subsequent configuration document is attached to each IMG node in configuration tab.  ( like same IMG node  -  define order types used in different business process configuration tab )
    when i use " where used list " from the configuration tab , its not showing the IMG objects  used in different business processes in the same project. whereas its showing the IMG nodes used in the different project.
    I need to find out the same IMG objects/ document  used in the same project using the " Where used list " button.
    Please provide your answers
    Note : we have linked one configuration document to same IMG nodes used in different business. " where used list " also not working for documents as well
    Thanks
    Sol man

    Hello there,
    I just tried some tests and couldn't face any problem with locating other usages for the objects in configuration tab.
    You mentioned a configuration document, so have in mind that the document usage will only be considered if it is a link to the same document and not just a copy.
    e.g:
    Here I created a document in this node:
    Then I added it as a link here:
    and as a copy here:
    When I go back to the original node and use the where-used, it'll only show the original and the link:
    This happens because after copying a document, it is considered as a new one instead of another usage of the original one.
    best regards,
    Fabricius

  • I keep getting a message that my ipad could not be activated because activation server is unavailable and when i try to use itune its not working as well.Plssss help

    i keep getting a message that my ipad could not be activated because activation server is unavailable and when i try to use itune its not working as well.Plssss help

    Has this iPad ever been jailbroken, had the OS rolled back, or used a beta version?

  • Using cron-job to call the PL/SQL procedure for every 5 min

    Hi All,
    i wrote one procedure. using cron-job to call this PL/SQL procedure for every 5 min. i don't have any idea about cron job & what is thescript file formate .where can i place that script file. what are the details we placed in that script

    Really appreciate you. I like this approach .
    please give me advice for the below thing
    job_action =>an i give my procedure name under this?
    BEGIN
    -- Job defined entirely by the CREATE JOB procedure.
    DBMS_SCHEDULER.create_job (
    job_name => 'Job_schedule_update',
    job_type => 'PLSQL_BLOCK',
    job_action => 'BEGIN Schedule_update; END;',
    start_date => SYSTIMESTAMP,
    repeat_interval => 'FREQ=HOURLY;BYMINUTE=5',
    end_date => NULL,
    enabled => TRUE,
    comments => 'Job defined entirely by the CREATE JOB procedure.');
    END;

  • Validations using OB28 is not working for GL posting using FB01

    Hi Experts,
    Validations using OB28 for posting using FB01 is not working.
    My requirement is after entering a line items and click post validations should be triggerd.
    i want to block a posting based on document type.
    i have maintained as below..
    Prerequisite.
    ( BKPF-TCODE = 'FB50' OR BKPF-TCODE = 'FB01' ) AND (
    BKPF-BUKRS = '1000' OR BKPF-BUKRS = '0001' OR
    BKPF-BUKRS = '0002' ) AND BKPF-BLART = 'XX'.
    check.
    Used userexit to check sy-ucomm = 'BU'  (for posting).
    entries are maintained in OB28 for relevant company codes.
    it is working for FB50 but not FB01.
    same thing i tried to maintain at header level as well as item level. but it is working only for FB50 but for FB01.
    Please help me.
    Regards.
    Venu.

    Hi Venu,
    Go to GGB0 and expand the navigation till you reach the validation name of line item level and choose menu item *Validation -> Simulate.
    Here you can enter the inputs, those you are entering while doing FB01 and execute it.
    Then in the results, you will have the log for each step of your total validation of line item level.
    Check , whether your questioned STEP's pre requisite is met and check is not fullfilled.
    Accordingly you can make the changes to the STEP.
    This info may help you.
    Regards,
    Srinivas

  • Cron job not running - script uses rsync, ssh (with id_rsa)

    Does anyone know how to get cron to run a rsync/ssh script which uses id_rsa for passwordless logins?
    I have a backup script I have slaved for months over that works wonderfully when running it from the command line.
    It uses rsync and connects with SSH (passwordless using ssh keys). I have setup id_rsa and id_rsa.pub for passwordless logins (this is my user account, and connects using root@ to the server)
    As stated all works find when run from the command line. But when I setup a cron job to run this file (exact same line I run from the command line) it does not execute. Actually, it does run, as I have an email notifiction which sends to me. It is just the rsync/ssh part that does not run.
    I have spent days and days trying to figure it out. No error messages occur, nothing.  Took me a while to find out cron is emailing the user account on Lion the messages (not to a proper email address).
    The error shows a permission denied, which I believe to be the cron user cannot use the id_rsa/ssh connection.
    Cron is running the script as my user, the same I use on the command line. I even tried copying the id_rsa to the root user .ssh folder in case cron is running as root but that does not work either.
    So does anyone know how to get cron to run this rsync/ssh script which used id_rsa for passwordless logins?
    Thanks a lot

    YES! Got it working, finally!
    So the issue is indeed cron/launchd not being able to access the ssh-agent which holds the key.
    So this is the solution...
    Download keychain for Mac:
    http://www.funtoo.org/wiki/Keychain
    Then once its installed and configured, the script to run needs this added to the top:
    eval `keychain --noask --eval id_rsa` || exit 1
    Note I am using id_rsa whereas keychains instructions refer to id_dsa so I just changed it and it works OK.
    When the script runs the first time it asks for the key password. Then it works from then on.
    What I do not know yet is will I need to re-enter the password when I logoff/logon again. That will cause an issue as I auto restart the Mac every day which means if I am off for a few days backup will stop (can you see the madness in this issue!).

Maybe you are looking for

  • Epson Stylus Photo 1290 - how do I remove items from the print queue?

    Description of problem with "Epson Stylus Photo 1290" Application: After selecting Show Completed Jobs from the main menu (Jobs > Hide/Show Completed Jobs) I am presented with a status list of print jobs (a.k.a. "print queue") that are either marked

  • Error in F-53

    Hi, I have an error while making a partial payment the error is "Special G/L indicator  not defined or incorrect" i have defined the Sp gl. please let me know the issue Point will be assigned Regards Pady

  • Oracle Application Migration

    Hi Iam Using Oracle Application server 10g. I have to upgrade the applications - (Forms 10g/Reports 10g), Some Java servelets, php applications to a new hardware with Oracle Application Server 11g. Whats the step by step procedure. Actually it's part

  • Generating dynamic columns for a report

    Hi all,       Can anybody pls. tell me how to output dynamic columns in a report. my req. is that i've to generate so many columns as there are no. of unique(a particular field value) rows in my internal table. for e.g say suppose i've 5 rows in my i

  • In Firefox, I can NEVER do the Adobe Flash Player 11 Update

    Question In Firefox, every time the Adobe Flash Player Update box shows up, I click on it, it scrolls right as it downloads, then I am asked to read the license, which take me to a page of a thousand license agreements. I choose the Flash Player 11 l