I just want to write a little shell script, which restarts my dosbox everytime it crashes.
#!/bin/bash
while [ "1" == "1" ]
do
test=$(pgrep dosbox)
if [ "$test" == '' ]
then
date + "%d-%m-%y %T" >> autostartLog.txt
dosbox emulator
fi
done
and it restarts fine, but I can't write into my autostartLogs.txt.
I tried
echo $(date + "%d-%m-%y %T) >> autostartLog.txt
in the terminal and it worked perfectly, but if I use it in my script it doesn't do anything.
edit: used checker, but it still doesn't write.
test =$(...)is wrong, know why)."%d-%m-%y %Tbash -x script-name. Mydatecommand fails if there is ` space after the+dateprobably doesn't like the space after the+. Doesdate + "%d-%m-%y %T"work when run manually? Could you try addingset -exto the top of the script?date + "%d-%m-%y %T"with a space prints a date? Mine doesn't. Now I'm confused about what works and what doesn't (and what's this about terminal windows?!). Could you clarify, perhaps edit the question? (set -exwasn't supposed to solve as much as help debug.)