Cron job won't execute manually

I’m currently testing a shell script.
Everything works more or less when I input it manually via ssh.

So I tried the next step of making it run with a schedule.

I just can’t get script to execute manually. It doesn’t matter whether the script is set to disabled or on a schedule.
It always says “Job Completed Successfully”, while doing literally nothing.
It also doesn’t seem to matter if I wrote the path to my file wrong or not.

I set the execute flags on the file, it has the shell command #!/bin/sh in the beginning.

I just don’t want to wait until the schedule to see whether my setup really works.

What could be my issue here?

Thanks!

The thing that always bit me with Cronjobs is that they have almost no SHELL Profile. So any PATH or other configurations that you rely on from your personal or root SHELL won’t be available.

So, all commands should be fully PATHed. Only trivial SHELL commands like echo can be left without directory paths.

Other than that, put in diagnostic lines, like:

#!/bin/sh
echo >/root/cronjob10.log
echo "Starting command 1" >>/root/cronjob10.log
/path/to/command1 2>&1 >>/root/cronjob10.log
echo "Starting command 2" >>/root/cronjob10.log
/path/to/command2 2>&1 >>/root/cronjob10.log

Thanks. Yeah this was the issue. I didn’t define the shell to use in the command in the contab.
After using zsh myPath/myScript it works. :slight_smile:

1 Like