My crontab only worked when I was logged in as user.
I found the solution suggested here on Unix & Linux SE
What was the problem is that the scrips were in my home directory which was encrypted. So it will be unmounted and unavailable when I was logged of. You can use the command mount
to see if your home directory is mounted for encryption.
I fixed the problem by putting my scripts in the /usr/local/bin
folder.