Any way to have a script run at a specific time of day?

Discussion in 'Mac Apps and Mac App Store' started by debo, Apr 7, 2004.

  1. debo macrumors regular

    Joined:
    Jan 9, 2004
    #1
    How can I have a script in unix execute at a certain time during the day?
     
  2. switcheroo macrumors newbie

    Joined:
    Oct 27, 2003
    #2
    cron is your friend

    you can do it the same way osx runs its maintainence tasks as well as most other unicies by using the cron daemon. add an entry to the file /etc/crontab you can use the existing entries as examples and find out more in 'man 5 crontab'
     
  3. debo thread starter macrumors regular

    Joined:
    Jan 9, 2004
    #3
    Is there any other way? This is just something I need to run like 5 times tommorrow as a project, and didn't want to have to be next to the computer each time. Then I won't be running it again after tomorrow.
     
  4. switcheroo macrumors newbie

    Joined:
    Oct 27, 2003
    #4
    yep there is. but you still need to mess with cron!! use the 'at' command. It is disabled in mac osx so you need to enable it by removing the comment symbol # in /etc/crontab
    making
    #*/5 * * * * root /usr/libexec/atrun
    into:
    */5 * * * * root /usr/libexec/atrun

    then to use the at command --

    to run at a certain time today use:
    echo 'open file.txt' | at 10:40 pm

    or at a time tomorrow:
    echo 'open file.txt' | at 10:40 am tomorrow

    or at a certain date and time:
    echo 'open file.txt' | at 10:40 am 4/8/04

    or even at teatime!
    echo 'open file.txt' | at teatime

    try it out a few times times within a few minutes to make sure your syntax is correct

    if your script doesn't need arguments use
    at -f script 11:00 pm

    to see the at job queue use atq
     
  5. siliconjones macrumors member

    siliconjones

    Joined:
    Feb 19, 2004
    #5

Share This Page