Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm stomped on how to accomplish this task. I need to run this script that fills up the nand flash on an embedded (linux-Busybox v1) device with random data, then continually repeats this process until the user stops it or the flash drive fails. The problem I'm having is that my testing involves power-cycling the device several times. But, the script stops running, which calls for me to start it again manually. Can someone recommend a resolution? Thanks!



mkdir -p /mytest/storage/testnand

while true
#./ >/mytest/storage/testnand/test.raw
dd if=/dev/urandom of=/mytest/storage/testnand/test.raw bs=100000 count=50 2> /dev/null
if [ ! $? = 0 ]
    echo "ERROR: ${idx}"
    echo "ERROR: ${idx}" >> /mytest/storage/testnand/error.log
cp /mytest/storage/testnand/test.raw /mytest/storage/testnand/test_copied.raw
if [ ! $? = 0 ]
    echo "ERROR 1: ${idx}"
    echo "ERROR 1: ${idx}" >> /mytest/storage/testnand/error.log
cmp /mytest/storage/testnand/test.raw /mytest/storage/testnand/test_copied.raw 2> /dev/null
if [ ! $? = 0 ]
    echo "ERROR 2: ${idx}"
    echo "ERROR 2: ${idx}" >> /mytest/storage/testnand/error.log
echo "OK ${idx}"
echo "OK ${idx}" >> /mytest/storage/testnand/ok.log

idx=`expr $idx + 1`


I failed to mention, as I didn't have this information at the time, the embedded os is patched: there are many files that are read-only; /etc/rc is one of those files. Is there some kind of work-around that will allow me to run my script at start-up?

share|improve this question

You could add the following to /etc/rc.local:

sudo -u ${USERNAME-TO-RUN-AS} tmux new-session -d -s ${NAME-FOR-SESSION} -d 'sh /path/to/your/script'

Then you can type "tmux attach namefortmuxsession" to view the terminal output from your script.

Replacing /path/to/your/script',$(USERNAME-TO-RUN-AS)and${NAME-FOR-SESSION}` to suit you needs.

Of course, you'll need tmux installed. You could probably do this with screen instead, however I prefer tmux.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .