I have a csh script (I have to use csh, I can't use bash) called new_script which calls another script called soak_script 12 times. The soak_script sleeps for 12 hrs and then does some tests.
My problem is that my original script (new_script) terminates automatically after soak_script executes once. If I reduce the sleep time from 12 hrs to 30 sec, the entire script works fine and soak_script is executed 12 times as it should. Why is this happening? Please help me. I am a beginner at linux and scripting and I am really lost.
#!/bin/csh -f
clear
echo "*****************************SIMULATION STARTED***********************************"
echo ""
echo "Sim Start Time : `date`"
echo "Sim Folder : ${cwd}"
echo ""
ls | grep -E 'soak|scan' > ls_all
echo "List of all simulation sub-folders:"
cat ls_all
echo ""
foreach line ( "`cat ls_all`" )
if ($line =~ *scan*) then
cd ..
echo "CURRENT DIRECTORY: ${PWD}"
echo "Copying char_nosleep.c to char.c"
cp char_nosleep.c char.c
if ($? != 0) then
echo "Copying failed"; exit 2
endif
cd /u/rahul7/p4/prod/virgo2/diags/src
echo "CURRENT DIRECTORY: ${PWD}"
echo "Making char_nosleep.c for $line"
make
if ($? != 0) then
echo "Making failed"; exit 3
endif
wait
echo "****************************************************************************************************************************************************************************"
cd bin/vdma/TestSet2_100_100
cd $line
echo "CURRENT DIRECTORY: ${PWD}"
echo "RUNING.."
echo "Run Start Time : `date`"
ls | grep ^data > ls_run
foreach command ( "`cat ls_run`" )
if ($command =~ *Micron*) then
./$command > mcrn_run_out &
else if ($command =~ *Samsung*) then
./$command > ssung_run_out &
else if ($command =~ *Toshiba*) then
./$command > tshba_run_out &
else
echo "Micron, Toshiba or Samsung run file not found in $(pwd)!"; exit 4;
endif
end
wait
rm -f ls_run
echo "Run End Time : `date`"
echo "****************************************************************************************************************************************************************************"
cd ..
else if ($line =~ *soak*) then
cd ..
echo "CURRENT DIRECTORY: ${PWD}"
echo "Copying char_sleep_12hr.c to char.c"
cp char_sleep_12hr.c char.c
if ($? != 0) then
echo "Copying failed"; exit 2
endif
cd /u/rahul7/p4/prod/virgo2/diags/src
echo "CURRENT DIRECTORY: ${PWD}"
echo "Making char_sleep_12hr.c for $line"
make
if ($? != 0) then
echo "Making failed"; exit 3
endif
wait
echo "****************************************************************************************************************************************************************************"
cd bin/vdma/TestSet2_100_100
cd $line
echo "CURRENT DIRECTORY: ${PWD}"
echo "RUNING.."
echo "Run Start Time : `date`"
ls | grep ^data > ls_run
foreach command ( "`cat ls_run`" )
if ($command =~ *Micron*) then
./$command > mcrn_run_out &
else if ($command =~ *Samsung*) then
./$command > ssung_run_out &
else if ($command =~ *Toshiba*) then
./$command > tshba_run_out &
else
echo "Micron, Toshiba or Samsung run file not found in $(pwd)!"; exit 4;
endif
end
wait
rm -f ls_run
echo "Run End Time : `date`"
echo "****************************************************************************************************************************************************************************"
cd ..
endif
end
rm -f ls_all
echo "Sim End Time : `date`"