crontab fails to write logs

Solution 1:

When you chain commands and add redirection like

cmd1 && cmd2 && cmd3 >> somefile 2>&1

(or cmd1 ; cmd2 ; cmd3 >> somefile 2>&1 etc.) the redirections only apply to the last command in the chain. To redirect all of them, you need to group the commands like

{ cmd1 && cmd2 && cmd3 ; } >> somefile 2>&1

or (with a subshell)

( cmd1 && cmd2 && cmd3 ) >> somefile 2>&1

In this case, your cron job is likely failing at the very first source command, since source is a bashism and cron's default shell is /bin/sh - either add SHELL=/bin/bash before the crontab entry, or change source to the POSIX .