Hi there,
I have an script reading content of a file and runs whatever command is specified there, as follows
#!/bin/bash
# Supposed to read from a file that commands are listed to be run
# when the server starts for initialization
CMD_FILE=/myScripts/startup/task2do.txt
if [ ! -e $CMD_FILE ]; then
echo "No task file found as $CMD_FILE!" >&2
exit 1
fi
grep -v ^# $CMD_FILE| while read line; do
. $line
done
echo "All tasks been done!"
exit 0
I tried to source/call directly and it's working fine however, if the command that it is supposed to execute ends with &,it doesn't go through all the commands sequentially. Could you please tell me how should I write this code that even if the command it's going to execute is like a simple while-sleep deamon written.
Many thanks,