Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

rediffusion

macrumors regular
Original poster
Jun 26, 2006
202
38
Fairfield, CT
Probably a silly question...

I have created an AppleScript to run Dropbox....

tell application "Finder"
activate
open application file "Dropbox.app" of folder "Applications" of startup disk
end tell

I want to make it run at 1am every night but can't work out how to do it. Do I use Automator?


Thanks in advance,
R ;)
 

kryten2

macrumors 65816
Mar 17, 2012
1,114
99
Belgium
Probably a silly question...

I have created an AppleScript to run Dropbox....



I want to make it run at 1am every night but can't work out how to do it. Do I use Automator?


Thanks in advance,
R ;)

Here's an launchd example that should run Dropbox every day at 1am. Save the below snippet into a plain text file in your ~/Library/LaunchAgents folder with the file name user.dropbox.nightly.plist

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
          <key>Label</key>
          <string>user.dropbox.nightly</string>
          <key>ProgramArguments</key>
          <array>
                    <string>osascript</string>
                    <string>-e</string>
                    <string>activate application "Dropbox"</string>
          </array>
          <key>StartCalendarInterval</key>
          <dict>
                    <key>Hour</key>
                    <integer>1</integer>
                    <key>Minute</key>
                    <integer>0</integer>
          </dict>
</dict>
</plist>

You can test it by using the following command in the Terminal application :

Code:
# this line loads the launchd job
launchctl load Library/LaunchAgents/user.dropbox.nightly.plist

# this line forces the job to trigger immediately rather than waiting until 1am
launchctl start user.dropbox.nightly

# this line unloads the plist, in case there's an error
launchctl unload Library/LaunchAgents/user.dropbox.nightly.plist
 

Attachments

  • Picture 3.png
    Picture 3.png
    98.3 KB · Views: 470
  • Picture 4.png
    Picture 4.png
    44.4 KB · Views: 423
Last edited:

Johnny83

macrumors newbie
Dec 25, 2016
7
0
Hi kryten2!

On this topic I have a apple script which auto connects the vpn if it drops I would like to run it between 6pm and 8am. Can you help me with this please?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.