MESSAGE=Hello World
***** /bin/sh ~/script.sh >> /tmp/script.log
Now, can the same environment variable MESSAGE be passed to the shell script ~/script.sh that being scheduled to run every minute? Let’s just give a try by adding the following line to script.sh:
echo"ECHO: ${MESSAGE}"
tail -f /tmp/script.log:
ECHO: Hello WorldECHO: Hello WorldECHO: Hello World
Therefore, the shell script will pick up the environment variables defined in crontab. This really is a convenience.
Because CoffeeScript binary (coffee) use the following format:
#!/usr/bin/env node
Which does not specify fully qualified path on the shebang line, and will result in:
/usr/bin/env: node: No such fileordirectory
We can compile CoffeeScript into JavaScript and use fully qualified node executable. But this is not necessary. Since we are using Debian based system, which uses Vixie cron. It allows environment variables to be defined. We can make Cron aware of the custom path in environment variable: