I’d like to automatically copy the contents of a file file.a to file.a.b whenever file.a is saved by any program. The following is what I tried so far with a LaunchAgent, but it doesn’t work yet.

1. Create script to copy the file contents

say "Script is running"
cd /path/to/folder
cat file.a > file.a.b

make it active with chmod -x copy.sh. This script works when I run it manually via sh script.sh or with a global hotkey from Alfred.

2. Create a LaunchAgent
I build it with Lingo but saved it manually since Lingo won’t save the file …

<?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">

3. Save LaunchAgent
I saved the agent as ~/Library/LaunchAgents/de.tweh.DoCopy

4. Restart
Restart my Mac to activate the LaunchAgent.

What am I doing worg?

The Console gives this (useless?) error message:

16.06.13 00:44:04,005 com.apple.launchd.peruser.502[153]:
(de.tweh.DoCopy[326]) Job failed to exec(3) for weird reason: 13

closed as too localized by user151019, nohillside Jun 16 '13 at 11:37

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Have you looked at the Console application to see what the logs say? – ayaz Jun 15 '13 at 17:41
  • @ayaz: Not yet, but it isn’t helpful (for me) … see my edit … – Tobi Jun 15 '13 at 22:44
  • @ayaz: Thanks that led me to the solution :-) – Tobi Jun 16 '13 at 10:23

I found the error: I used chmod -x instead of chmod +x. Now it works fine :-)

Not the answer you're looking for? Browse other questions tagged .