Sometimes, script that works well in command shell, doesn’t work correctly in ‘cron’.
In this case, following should be checked firstly.
‘cron’ uses initial environment varialbe. And in this case, ‘/bin/sh’ is used as a shell.
In case of some high-version-ubuntu, ‘/bin/sh’ is not ‘bash’ but ‘dash’. And this can be root cause of this issue.
To avoid this, we should always add “#!/bin/bash” at the top of bash script, habitually.