I have a script that requires the env variable USER to be set. As the script is used by several users, I can’t just do export USER=xxx at the beginning of the script. I could define in the crontab, but I was just wondering whether there is a good way of pulling it in.
I tried sourcing .bashrc and .profile, but neither define USER, plus on Ubuntu .bashrc simply returns on non-interactive shells.
You could work around it by writing at the top of the script (Bashism):
or old-style:
… assuming you have
whoamiin thePATH, which can also be set in thecrontabjust like several (most?) other variables. I.e. you can also set the variable incrontabitself (at least in Vixiescron) – see here for example.