Support
Quality
Security
License
Reuse
kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample Here
Get all kandi verified functions for this library.
Cross platform
Support for the official Dropbox API v2
No password required or stored
Simple step-by-step configuration wizard
Simple and chunked file upload
File and recursive directory download
File and recursive directory upload
Shell wildcard expansion (only for upload)
Delete/Move/Rename/Copy/List/Share files
Create share link
Monitor for changes
QUESTION
launchd - how to keep script running in the background
Asked 2021-Jan-03 at 18:42I have a simple script to upload the file to dropbox whenever it changes. I wanted to run it at system startup and keep it in a background to let the script watch the file.
I've created a plist, however it runs the script and exits with code 0.
plist
<?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.example.launchd.dropbox_uploader</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>~/dropbox-uploader.sh; wait</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
(doesn't work neither with, nor without wait
in the command)
script (it works fine and doesn't exit when run in command line)
#!/bin/sh
fswatch -o ~/file.txt | xargs -n1 -I{} curl -X POST https://content.dropboxapi.com/2/files/upload \
--header 'Authorization: Bearer XXXXX' \
--header 'Content-Type: application/octet-stream' \
--header 'Dropbox-API-Arg: {"path":"/backup/file.txt","strict_conflict":false,"mode":{".tag":"overwrite"}}' \
--data-binary @'~/file.txt'
launchtl list
output
~> launchctl list | grep com.example (base)
- 0 com.example.launchd.dropbox_uploader
How to achieve my goal to have it run in the background? I'm not sure if there's an issue with my plist or script.
ANSWER
Answered 2021-Jan-03 at 09:22Edit crontab file with crontab -e
and add the following to that file:
@reboot /path/to/job
This will run your job every time your system reboots and keep it running in the background.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
See Similar Libraries in
Save this library and start creating your kit
Open Weaver – Develop Applications Faster with Open Source