1

Say I have a script named "mydailyscript" containing the following:

#!/bin/bash if [ ! -z $MYDAILYLOG]; then exec 1>$MYDAILYLOG fi echo This script ran on $(date)

and I then copy this script to /etc/cron.daily.

Where do I define the environment variable, MYDAILYLOG? i.e. MYDAILYLOG=/var/log/mydailylog

Do I append a line to /etc/environment?

sudo echo "MYDAILYLOG=/var/log/mydailylog" >> /etc/environment

AWM
  • 55
  • 5

1 Answers1

0

If you want to add a variable to for all users of your system, you add it in the /etc/environment. It is global environment file.

You want to define variable for your current script only, you can use the path as a regular variable before the place where you have used the variable or you want to add the path as a variable, you can use export also.