I've installed a version of Ubuntu Server and although I'm fairly still fresh with Ubuntu, I'm trying to create a bash file to run a program in the background. More importantly, I'm trying to get a file nameto display correct and create it before I start running the program (I like my debug stuff).

However, here is my bash script:

 DATE=$(date +%d-%m-%Y)

I have verified that the file does exist in the PATH directory. However, the issue is with the date command. When I run the script bash -x game.sh this is what is displays.

 + PATH=/var/log/servers/Game/
 + FILENAME=startup
 + EXT=.log
 ++ date +%d-%m-%Y
 game.sh: line 5: date: command not found
 + DATE=
 + NEWFILE=/var/log/servers/Game/startup_.log
 + echo /var/log/servers/Game/startup_.log

I don't understand why it would say the command doesn't work, when I can go to the main console and run date and get a valid response.

Any help is greatly appreciated!


This sets the PATH to just that directory, and I doubt that directory contains date.

Be careful when you use uppercase variable names, you could easily be stomping over a standard environment variable.

Stick to lowercase, and be more descriptive. Consider using, for example:

  • Wow, now don't I feel like a dummy. X_X. Thank you for this simple solution. – Twister1002 Aug 6 '15 at 3:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.