I want to run a bash script on startup of my Parallella board, which has Ubuntu. I searched in SO, and found the instruction in here:
My bash script is test.sh
, which has only one line:
echo "Hello World" &> /home/qsp/WIP/test/hello.txt
1) The first way I tried is adding to /etc/rc.local
the aboslute path to the script:
/home/qsp/WIP/test/test.sh
2) The second way I tried is following the accepted answer above.
sudo mv test.sh /etc/init.d/
sudo update-rc.d test.sh defaults
In both cases, the script was executed after booting, and there was a file hello.txt
created in the folder. However, the content of the file is empty (and the owner is root). I wonder if I'm missing anything. Thank you.
======UPDATE=======
Following the answer of Skynet, I change my script to:
echo "Hello World" | tee /home/qsp/WIP/test/hello.txt
and the script writes to the file after booting correctly. I have another question, why my original script with &>
didn't work, although it still works if running from command line.