Scheduling application using launchctl for logged in user

amrapali

Registered
Hello,

I have to implement an application for scheduling an command line exe to do some background task. I have to support Mac OS 10.4 & above.

Following are requirements of my application:
1. Run at first boot.
2. Set the priority of exe (high/low).
3. Schedule task per user

I have created a plist file as follows and placed it in ~/Library/LaunchAgents.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.test.launchexe</string>
<key>ProgramArguments</key>
<array>
<string>/Users/macadmin/tryouts/sample</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>LaunchOnlyOnce</key>
<true/>
</dict>
</plist>

My questions are:
1. For launching my application after boot (& user login):
Do I have to initially load the plist using launchctl or just placing the plist in ~/Library/LaunchAgents directory is enough?
If I load the plist explicitly, the application starts running immediately as the plist is loaded. But I want it to run after next boot.
If I set the RunAtLoad key to false, application does not start after boot.
2. What care should be taken for multiple users? Do I have to store the user id?
3. When plist is modified by user after loading, do I have unload the plist and load again for reflecting the new changes? (e.g: task scheduled to run after every 5 min, is changed to run after 10 min.)
4. Also I want to prevent modifications to plist file by other users and other applications.
5. For setting the priority, do I require root privilege or specifying nice key will do ?
6. When loading,"launchctl load -w ~/Library/LaunchAgents/com.test.launchexe.plist", I get "nothing found to load" error. Why this happens? How to resolve this?
7. Is there another way to achieve it? I know about crontab but it is deprecated.

Thanks,
Amrapali.
 
Referring to step 6 - if that's actually an .exe (a Windows executable app), then you can't do that in OS X.
A Windows .exe won't run in OS X.
What app is this, exactly?
 
Referring to step 6 - if that's actually an .exe (a Windows executable app), then you can't do that in OS X.
A Windows .exe won't run in OS X.
What app is this, exactly?
I have to create a cocoa GUI application which take user input for executing a task:
- at first boot OR
- at particular time.
The task is a exe (command-line tool that links against the Foundation library) created using XCode.
It is not a windows executable.
 
Back
Top