I have a bash script imagecopy.sh
that backups images which are located in a subdirectory with a prepended date string: this works perfectly fine when I execute it from the directory it resides in - /Users/danny/Library/Caches/
.
The script is
#!/usr/bin/env bash
cat himawaripy/latest.png > himawaripy/output/$(date "+%Y.%m.%d-%H.%M.%S").png
I have also added the directory where the script is located to my $PATH
using nano .profile
and confirmed this using echo $PATH
.
/Users/danny/Library/Caches:/Users/danny/anaconda/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/TeX/texbin
I would like to run the bash script periodically using a LaunchAgent, located in /Users/danny/Library/LaunchAgents
.
The LaunchAgent file com.user.imagecopier.plist
references the script location by the lines..
..other code
<key>Program</key>
<string>imagecopy.sh</string>
...etc
I presume there is a mistake linking the LaunchAgent file to the script, any suggestions would be greatly appreciated.
Edit: Updated LaunchAgent File as Suggested
<?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.user.imagecopier</string>
<key>ProgramArguments</key>
<array>
<string>/Users/danny/Library/Caches/imagecopy.sh</string>
</array>
<key>Nicer</key>
<integer>1</integer>
<key>StartInterval</key>
<integer>60</integer>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
cat
to copy files? Use the keyProgramArguments
with the absolute path to the script. And the absolute paths to the source file and destination file within your script.cat
ing a file to another looks kind of strange, just usecp
(if you want to keep the source file) ormv
(if you only want to rename it).<key>ProgramArguments</key>
here?