I have this in my crontab:
* * * * * cd /etc && . ./cron.sh>>cron.log
In my cron.sh (which is executable) I have:
#!/bin/sh
echo "hello world"
export MyVar="abcd"
It runs both with cron and manually, however the environment variable is only set when I run it manually with the command:
. ./cron.sh
Can anyone please help. I know its something to do with source but I cant figure it out.
This does not work either:
* * * * * cd /etc && sh ./cron.sh>>cron.log