Coolest Guides on the Planet

coolest guides on the planet

Coolest Guides On The Planet

  • Home
  • macOS
  • WebDev
  • All Posts
  • Contact

Scripting OS X Launchd Agent to run a Backup Command

July 19, 2011 Leave a Comment

script-scp-backup

script-scp-backup

In OS X 10.7 the launchd process is the process that kicks off all processes and launches launch daemons and launch agents. This effectively is what cron and cronjobs are to the general Unix/Linux environment

Launch Daemons are typically system process whereas Launch Agents are processes that can be run by users.

Launch Daemons are found in 2 spots :

/Library/Launch/Daemons <<–3rd Party Daemons
/System/Library/Launch/Daemons <<–Apple Daemons

 Launch Agents are found in 4 spots:

/System/Library/LaunchAgents <<–Apple supplied agents for all users
/Network/Library/LaunchAgents <<–Network Users via an automount
/Library/LaunchAgents <<–Third party agents for all admins
~/Library/LaunchAgents <<–Third party agents for all users

These files are plain text xml files or  .plist “property list” files and are structured in value pairs, you can edit with a regular text editor or using Apple’s Property List Editor which comes in the Developer Tools: Developer/Application/Utilities, the files also have a reverse URL naming convention ie :

 com.neilgee.mysuperbackup.plist

A native plist looks like this:

<?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>com.neilgee.mysuperbackup</string>
<key>ProgramArguments</key>
<array>
<string>/usr/sbin/ftpcpanel.sh</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>10</integer>
<key>Minute</key>
<integer>17</integer>
</dict>
</dict>
</plist>

And a view via the Property List Editor looks like this:

property-list-editor-osx

property-list-editor-osx

 

The one that applies to any 3rd Party automation for users is the agents filed in the users folder in:
~/Library/LaunchAgents <<–Third party agents for all users

And a great application for creating Launch Agents graphically is an app called “Lingon” by Peter Borg which allows you to create a new agent, name it, point to the command you want to run, set the frequency interval and set and forget.

So if you already have a script made for backups to download a cPanel backup from a remote host you can set when that script is run and the backup is launched.

In Lingon fill out the steps 1 2 and 3…

 

lingon-script-osx-backup

lingon-script-osx-backup

Cats: macOS Tags: backup, cron, launchd, lingon, lion, OSX, scripting

Tags

3gs 10.6 apache backup baseband boot clean urls cpanel css curl custom database drupal el capitan git Google image instadmg ios iphone jailbreak keys lion mac macos mojave macos sierra menu mysql OSX panda php phpmyadmin private public redirect redsn0w remote rsa SEO shell ssh terminal unstoppables upgrade urls

Donate a Beer to the Coolest Guides

Get Beaver Builder Now!

Copyright © 2023· Neil Gee - All Rights Reserved - Hosted by Runcloud

Copyright © 2023 · gee on Genesis Framework · WordPress · Log in