Go Back   The macosxhints Forums > OS X Help Requests > Applications



Reply
 
Thread Tools Rating: Thread Rating: 4 votes, 5.00 average. Display Modes
Old 12-04-2007, 02:48 PM   #1
srdriggers
Guest
 
Posts: n/a
Smile Automatically Start and Stop any program by time?

Basically I have an application I want to be able to start every day at 3am and stop it every day at 6am. It is a file transfer program and my network connection removes download limits during this timeframe. Anyway, I am sure some guru out there can tell me an easy way to accomplish this task so...

I have an iMac running OS X 10.4.11

Thanks in advance.
  Reply With Quote
Old 12-04-2007, 04:26 PM   #2
cwtnospam
League Commissioner
 
Join Date: Jan 2005
Posts: 8,475
Is it Applescriptable? You could set iCal to run an Applescript to open it and do your downloads, then another to close it. That's the easiest way I know.

You could use launchd to launch a shell to do the same thing, but that requires some comfort with the Terminal.
cwtnospam is offline   Reply With Quote
Old 12-04-2007, 06:01 PM   #3
macosnoob
MVP
 
Join Date: Jan 2007
Posts: 1,895
I wonder whether QuitApp++ (which also appears to be able to launch apps according to its online help page) might do the job?

http://mactips-lib.net/m/software/qa/en/main.html
http://mactips-lib.net/m/software/qa/en/help.html
macosnoob is offline   Reply With Quote
Old 12-04-2007, 06:21 PM   #4
acme.mail.order
League Commissioner
 
Join Date: Sep 2003
Location: Tokyo
Posts: 6,330
Unattended processes are perfect for the terminal, but terminal stuff often doesn't mix well with the Desktop applications. Are you simply trying to upload/download a folder full of files? Very easy to do from the command line, but a few more details are needed from you.
acme.mail.order is online now   Reply With Quote
Old 12-06-2007, 01:38 PM   #5
patherto
Registered User
 
Join Date: Dec 2007
Posts: 2
This may not be what you need, but Carbon Copy Cloner is free and can be set up to back up part or all your files at any time you choose. Turns itself off, too.
patherto is offline   Reply With Quote
Old 12-06-2007, 07:00 PM   #6
acme.mail.order
League Commissioner
 
Join Date: Sep 2003
Location: Tokyo
Posts: 6,330
CCC is a backup program, it doesn't do file transfers to other machines.
CCC is also just a GUI wrapper for some terminal commands, scripting it to run at certain times is really doing things the roundabout way.
acme.mail.order is online now   Reply With Quote
Old 12-06-2007, 10:28 PM   #7
Jay Carr
Hall of Famer
 
Join Date: Sep 2004
Location: Springfield, MO, USA
Posts: 3,110
It's kind of a simpletons way of doing things. But if I want to do that I just set up the program to open at login, then I tell the computer to wake up at 3am and close at 6am. It's under energy saver under system prefs. I used to use it as a makeshift alarm clock as well...
__________________
~
Long ago I was called Zalister, keep that in mind when reading responses to my old posts.
Jay Carr is offline   Reply With Quote
Old 09-30-2008, 11:42 PM   #8
ozavanti
Registered User
 
Join Date: Sep 2008
Posts: 1
I was having the same issue and after a visit to the Mac Genius's no luck.

However today i found a program called "Timer" which appears to atleast start the program - no closing it down though.

http://www.apimac.com/index.php

Hope it helps.
ozavanti is offline   Reply With Quote
Old 10-01-2008, 05:42 PM   #9
tw
Hall of Famer
 
Join Date: Apr 2007
Posts: 4,262
use launchd. you can either do it with two plists, or with one plist and a script. the plist to launch the app looks like this:

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>my.openit</string>
	<key>ProgramArguments</key>
	<array>
		<string>open</string>
		<string>-g</string>
		<string>posix path to application package file...</string>
	</array>
	<key>StartCalendarInterval</key>
	<dict>
		<key>Hour</key>
		<integer>15</integer>
		<key>Minute</key>
		<integer>0</integer>
	</dict>
</dict>
</plist>
the '15' is 3 pm, and the '-g' option opens the app in the background. the plist to close the app looks like:

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>my.closeit</string>
	<key>ProgramArguments</key>
	<array>
		<string>killall</string>
		<string>appname...</string>
	</array>
	<key>QueueDirectories</key>
	<array/>
	<key>StartCalendarInterval</key>
	<dict>
		<key>Hour</key>
		<integer>18</integer>
		<key>Minute</key>
		<integer>0</integer>
	</dict>
	<key>WatchPaths</key>
	<array/>
</dict>
</plist>
save them as (say) my.openit.plist and my.closeit.plist in ~/library/LaunchAgents and restart (or use launchctl from the command line to load them)

you might want to shave 5 minutes off the 18 for close it - if your computer is working hard, launchd might not set this off exactly at the StartCalendarInterval time.
__________________
Philosophy is a battle against the bewitchment of our intelligence by means of language. -LW-
tw is offline   Reply With Quote
Old 04-02-2009, 12:03 PM   #10
serialband
Registered User
 
Join Date: Apr 2009
Posts: 1
Ok, a very old thread, but I think my information can still help some.

Mac OSX is a BSD unix variant. It's got crontab to schedule processes.

#on the command line, either with the Terminal utility, or X11 (if you've installed it.)
Code:
set EDITOR vi
or
Code:
set EDITOR emacs
or
Code:
set EDITOR Your_Favorite_Plain_Text_Editor
Then edit the crontab. If you've never used it you will have a blank file.

Code:
crontab -e
This stuff goes into the file.
Code:
# Enter the text following this comment.
# The '#' at the beginning of each line designates a comment in the crontab
# start your program at 3 am everyday
0 3 * * * /path/to/your/program
# at 6 am, search for the program and kill the process
0 6 * * * "ps -auxw| grep program |awk '{print $2}'|xargs kill"
Quit and save your file and everything should start. In the above example, be aware that the kill command allows you to kill all processes that match the name "program".

If you want to test out something simple, set your crontab to start up something simple. It's best to set the time for 5 minutes after the current time. You need at least 2 minutes. The crontab process may not restart fast enough to load the new times if you set it under a minute.

Here's some examples:
Code:
# Start your terminal at 11:47 am
47 11 * * * /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal
# at 11:50 am, search for the program and kill the process
50 11 * * * "ps -auxw| grep Terminal |awk '{print $2}'|xargs kill"
Code:
# If you have X11 installed, start X11 at 11:45 am
45 11 * * * /Applications/Utilities/X11.app/Contents/MacOS/X11
# at 11:50 am, search for the program and kill the process
50 11 * * * "ps -auxw| grep X11 |awk '{print $2}'|xargs kill"
Code:
# Start Safari at 1:59 pm
59 13 * * * /Applications/Safari.app/Contents/MacOS/Safari
# at 2:10 pm, search for the program and kill the process
10 14 * * * "ps -auxw| grep Safari |awk '{print $2}'|xargs kill"
serialband is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 12:42 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.