I have the following commands that need to be run in a shell script,
nohup command >> help.out &
When I run the script from terminal the nohup
command runs in the background and the next commands execute but the logs do not get written into help.out I have checked the permissions of the file help.out they were created as readonly in the script but I changed permissions using chmod -R 777 help.out and is no longer readonly, still nothing is written to help.out.
I would also like to know how to create the file or folder in a script so that it is never read only and has all permissions.
#!/bin/bash
trainingState=1
epoch=50
#URL myspace test
URL="xxxxxx"
nohup python3.6 <arguments> >> help.out &
#processId of xyz
processId=$(pidof python3.6)
#this command executes
curl -X POST -H "Content-Type: application/json" -d '{"markdown" : "### The Training has started !! \n > EPOCS:'"$epoch"'"}' $URL
#while loop also executes but no data to read from file
while [[ $trainingState == 1 ]]; do
if ps -p $processId > /dev/null ; then
echo "training happening"
value=$(tail -n 1 help.out)
curl requests etc .....
else
value=$(tail -n 1 help.out)
echo "training finished"
final curl requests etc .....
trainingState=0
fi
done