0

I'm trying to set up crontab to run a shell script, but for some reason, the script doesn't get executed. I'm on system with OS X 10.8.5.

crontab file

0 12 * * 1 /absolute/path/to/myscript.sh
0 15 * * 2 /absolute/path/to/myscript.sh
30 10 * * 3 /absolute/path/to/myscript.sh
0 18 * * 3 /absolute/path/to/myscript.sh
30 10 * * 4 /absolute/path/to/myscript.sh

myscript.sh

#!/bin/sh
cd /Users/me/Documents/targetfile/ && git add . && git commit -m "Added notes for $(date)" && git push -u origin master

The script runs fine when it's launched manually, using a shell, but produces only these entries in Console.app:

launchctl: launchctl: Dubious permissions on file (skipping): /Library/LaunchAgents/com.adobe.AAM.Updater-1.0.plist

I have executed chmod 777 myscript.sh as well as the error-raising .plist file, but to no avail.

EDIT: ls -l /Library/LaunchAgents/com.adobe.AAM.Updater-1.0.plist outputs:

-rwxrwxrwx  1 root  wheel  612  2 Aug 18:57 /Library/LaunchAgents/com.adobe.AAM.Updater-1.0.plist

and ls -ld /Library/LaunchAgents

drwxr-xr-x  22 root  wheel  748 10 Sep 21:12 /Library/LaunchAgents

I did set up the crontab using root, and I have no idea whatsoever what that plist has to do with the script I'm trying to do.

What's wrong with my setup?

Jules
  • 698
  • 4
  • 10
  • 26
  • Please edit your question to include the output of `ls -l /Library/LaunchAgents/com.adobe.AAM.Updater-1.0.plist` as well as `ls -ld /Library/LaunchAgents` (assuming OS X `ls` works similar to GNU ls). Also, please explain how it is related to your script. – user Sep 23 '13 at 14:59
  • Possibly relevant: [http://apple.stackexchange.com/questions/63857/launchctldubious-permissions-on-file-problem-installing-jenkins](http://apple.stackexchange.com/questions/63857/launchctldubious-permissions-on-file-problem-installing-jenkins) as well as [http://superuser.com/questions/238469/launchctl-dubious-ownership-on-file-skipping-mac-os-x](http://superuser.com/questions/238469/launchctl-dubious-ownership-on-file-skipping-mac-os-x) – Hennes Sep 23 '13 at 15:05
  • 1
    Are other commands (like for example `* * * * * say a`) run from crontab? Did you try adding the command to the user's crontab? – Lri Sep 23 '13 at 15:11
  • `* * * * * say a` doesn't work when crontab is edited from root or user. – Jules Sep 23 '13 at 15:31
  • 1
    I wonder if the "dubious" permission error is given because there are *too many* permissions: Try 755 instead of 777 – glenn jackman Sep 23 '13 at 17:39
  • I changed the permissions to `755` for all the files involved. Nothing shows up in the console, but the command doesn't fire off. I've now tried this with a GUI frontend, CronniX, and the command, `echo "Hello World!"`. Still nothing. – Jules Sep 23 '13 at 18:43
  • echo will not show up as an output of cron. You could `touch /tmp/unique_filename` if you want evidence that the cron was running successfully. – Kent Sep 23 '13 at 21:10
  • Alright, I've figured it out. The text editor I use was wrongly configured to insert several spaces instead of a tab when I pressed the tab key. – Jules Sep 23 '13 at 23:55

1 Answers1

0

add to your crontab line : &>/tmp/myscript.log

for example :

0 12 * * 1 /absolute/path/to/myscript.sh &>/tmp/myscript.log

and wait for the script to executes and check the myscript log, I assume that the possible errors will be " git command not found " or " cd command not found" , if that was the case then you have to locate the full path of theses commands via 'find' or 'locate' and enter its full path, for example instead of cd use /path_to_cd/cd etc..

Peter Hayek
  • 157
  • 1
  • 1
  • 11