linux - How to exit tail -f and resume script -
i have simple script, sets logging, runs tail -f on log file , then, after exit tail, performs cleanup. this
echo 'monitoring started' tail -f /var/log/some.log echo 'never gets here' problem is, exiting tail ctrl+c breaks script execution too, cleanup not called. there way 'properly' exit tail , resume script call? found few solutions based on saving pid , killing timeout, that's not want here, may need monitoring few minutes or few hours, i'd have manual switch.
you can this
echo "monitoring started" tail -f /var/log/some.log & #execute tail in background read -sn 1 #wait user input kill %1 #kill first background progress, i.e. tail echo "is reached"
Comments
Post a Comment