crontab: using ${USER}

SEU asked:

Right now I am writing some scripts that uses ${USER} to point to subsequent scripts. But when I run it from crontab, it errors out and the files are not found. I understand why.

I intend to share this with my colleagues and each time the colleague has to manually change the first line to his own username. How can I minimize this issue (not have a manual way to change that one line)?


My answer:

It’s a typo. You should use $USER, not ${USER}.

Cron parses these lines itself and does only simple variable substitution; it is not a shell.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.