xiº
xiº

Reputation: 4687

How to calculate variable in Upstart script and use it?

Is where any way to achieve this?

Some details:

I am trying to create log file for gunicorn with datetime in name.

Something like that, but it isn't works properly:

chdir /home/mypath
script
   log_file=./err_$(date +"%d_%m_%Y_%T").log
   exec gunicorn --error-logfile $log_file
end script

This approach fails too:

exec gunicorn --error-logfile ./err_$(date +"%d_%m_%Y_%T").log

Upvotes: 0

Views: 519

Answers (1)

chepner
chepner

Reputation: 532303

For some reason, the shell started by the script stanza is unable to find the date command in its path. Use a hardcoded path:

script
    log_file=./err_$(/bin/date +"%d_%m_%Y_%T").log
    gunicorn --error-logfile $log_file
end script

Upvotes: 1

Related Questions