Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- directory=/volume1/multimedia/Internet\ Radio\ Recordings/
- runtimeInSeconds=$((20*3))
- endSeconds=$((SECONDS + runtimeInSeconds))
- echo "Beginning..."
- while [ $SECONDS -lt $endSeconds ]; do
- fileName="TEST-"$(date +"%m-%d-%Y-%H%M(%S)")
- wget http://144.217.153.67/sj128.mp3 --timeout=1 --waitretry=0 --tries=1 -O "$directory$fileName.mp3" -q&
- nWgetPID=$!
- echo "Filename "$fileName" created with process "$nWgetPID
- # “kill -0 "$nWgetPID"” returns a process ID until...
- while kill -0 "$nWgetPID" >/dev/null 2>&1; do
- if [ $SECONDS -gt $endSeconds ]
- then
- echo killing the PID
- kill "$nWgetPID"
- else #the purpose here is to make sure it restarts the file when the PID dies prematurely
- if [ $SECONDS -gt 20 ]
- then
- kill "$nWgetPID"
- fi
- fi
- # runs every second
- # while loop ends when PID is killed
- #echo $SECONDS
- #echo kill -0 "$nWgetPID"
- sleep 5
- done
- done
- echo "Done. Reached "$endSeconds
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement