Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cybertk/launchd-oneshot
Run a oneshot job at next boot/login time
https://github.com/cybertk/launchd-oneshot
launchd-agent
Last synced: 2 months ago
JSON representation
Run a oneshot job at next boot/login time
- Host: GitHub
- URL: https://github.com/cybertk/launchd-oneshot
- Owner: cybertk
- Created: 2015-12-01T14:45:34.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-21T11:53:28.000Z (almost 9 years ago)
- Last Synced: 2024-04-14T23:28:40.807Z (9 months ago)
- Topics: launchd-agent
- Language: Shell
- Homepage:
- Size: 25.4 KB
- Stars: 23
- Watchers: 4
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# launchd-oneshot
> Run a oneshot job at next boot/login time on OSX
[![CI Status](http://img.shields.io/travis/cybertk/launchd-oneshot/master.svg?style=flat)](https://travis-ci.org/cybertk/launchd-oneshot)
## Installation
**launchd-oneshot** can be installed via Homebrew
```bash
brew install cybertk/formulae/launchd-oneshot
```## Getting started
To add a oneshot job `script.sh` to run at next boot time
```bash
sudo launchd-oneshot script.sh
```To add a oneshot job `script.sh` to run at next user login time
```bash
sudo launchd-oneshot script.sh --on-login
```To add a oneshot job `script.sh` to run at next user login time with root, and **launchd-oneshot** will pass current login user as `$1` to `script.sh`
```bash
sudo launchd-oneshot script.sh --on-login-as-root
```## Troubleshooting
logs is written to `/tmp/launchd-oneshot.log`, you can view it with
```bash
tail -f /tmp/launchd-oneshot.log
```## How does launchd-oneshot work?
**launchd-oneshot** installs a **launchd agent** under `/Library/LaunchDaemons` for each job. When agent is running, it will start **launchd-oneshot** in **RUN** mode, which will execute the origin job and remove the **launchd agent** when job is completed.
For `--on-login` job, in order to run the job as root, **launchd-oneshot** will install a trigger **launchd agent** under `/Library/LaunchAgents` in addition. When user login, the trigger agent will start running. And it will trigger the **launchd agent** under `/Library/LaunchDaemons` to run through launchd's `KeepAlive:OtherJobEnabled` mechanism.