Follow us on...
Follow us on Twitter Follow us on Facebook
Register
Results 1 to 3 of 3
  1. #1
    amrapali is offline Registered User
    Join Date
    Apr 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Scheduling application using launchctl for logged in user

    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.

  2. #2
    DeltaMac is offline Tech
    Join Date
    Jun 2001
    Location
    Dover, DE
    Posts
    7,695
    Thanks
    3
    Thanked 629 Times in 619 Posts
    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?
    Serendipity is a lucky guess !

  3. #3
    amrapali is offline Registered User
    Join Date
    Apr 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by DeltaMac View Post
    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.

 

 

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •