• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: AppleScript Timed Events
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript Timed Events


  • Subject: Re: AppleScript Timed Events
  • From: Deivy Petrescu <email@hidden>
  • Date: Tue, 17 Jun 2003 23:26:11 -0400

On Tuesday, Jun 17, 2003, at 14:59 US/Eastern, John Delacour wrote:

At 10:11 am -0400 17/6/03, Deivy Petrescu wrote:

Simone, forget what everybody else writes and use "at".
"man at" will give you more info, but , if it is not clear all post probably all you need.
...
It is the best thing you can hope to get


Looks good, but can you give us an example of a job that is an AS script, how to create it, locate it, name it etc. Like most man pages it assumes we were injected with the UNIX serum in infancy. There's noting like a working example to make things clear to a Machead.

JD


Sure!

First things first. If one is running X.1.x then one might need to create the /var/at/spool/ directory.
Use:
sudo makedir /var/at/spool/
*if you do not have the directory.* If you do, never mind this step.

Then you need to edit a file owned by root and it is not writable.
So...
sudo chmod 644 /etc/crontab
sudo vi /etc/crontab (or use your favorite editor instead)

Go to the line that contains:
#*/5 * * * * root /usr/libexec/atrun

and uncomment it, that is erase the # in front. Also you might one to change the 5 to 1 to get something like:
*/1 * * * * root /usr/libexec/atrun

this makes 1 minute the smallest interval between runs. "at" runs, that is. Leaving 5 makes 5 minutes the shortest interval... :)

You are ready to go.

To test, try the following, at the terminal prompt type "at now + 1 min" and then return
there will be a blank line type

osascript -e 'say "Hi!"' -- or whatever else you feel like -- and return

type control-d.

You should have a task to run 1 minute from now.
You can check that with

atq

which will give you something like

Date Owner Queue Job#
23:45:00 06/17/03 deivy a a010c87c5.000

Suppose you want to remove this job, then you would type

atrm a010c87c5.000

at the prompt.

So far nothing major. However, if you want to run a script at 11PM everyday from July 4th onwards, you would do the following.
Save the script as an application in you ~/bin/ directory, say, name it my_script.app
create a file named run_my_script in the same directory (not needed, but lets not complicate).
Type the following with your favorite editor

echo "run_my_script" | at now + 1 day
open ~/bin/my_script.app

save it as executable.

Now at the prompt type "at 11PM Jul 4" and return.
in the blank line type
~/bin/run_my_script --remember run_my_script should be executable -- and return

type control-d.

Now from July 4th onwards at 11 PM the script my_script.app will be run by "at" whether you are or not logged into the machine (the machine has to be on and sleeping will not do) or not.

If no one is administering anything and the use of "at" by other users do not bother you, that is it. If it does then read about at.allow or at.deny (in the /var/at/ directory).

You are done!






Regards

Deivy Petrescu
http://www.dicas.com/
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: AppleScript Timed Events (From: John Delacour <email@hidden>)

  • Prev by Date: Script to save and restore a session in TextEdit
  • Next by Date: Programatically determining default browser?
  • Previous by thread: Re: AppleScript Timed Events
  • Next by thread: Re: AppleScript Timed Events
  • Index(es):
    • Date
    • Thread