Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sure, here is a modified version of the previous script that uses nohup to run the script in the background and allows the user to stop the script by pressing any key:
- Copy code
- #!/bin/bash
- # Set path to file with URLs
- file="path/to/urls.txt"
- # Set interval (in seconds)
- interval=300
- while true; do
- # Read next URL from file
- url=$(head -n 1 "$file")
- # Open URL in new tab
- chromium-browser --new-tab "$url"
- # Remove URL from file
- sed -i 1d "$file"
- # Add URL to end of file
- echo "$url" >> "$file"
- # Sleep for specified interval
- sleep "$interval"
- # Check if user pressed a key
- if read -t 0; then
- break
- fi
- done
- To use this script, save it to a file and make it executable with chmod +x <filename>. Then, create a text file with the list of URLs you want to open, one per line, and specify the path to the file in the file variable. Finally, run the script with nohup ./<filename> &, which will run the script in the background and allow you to close the terminal without stopping the script.
- To stop the script, you can use the fg command to bring it to the foreground and then press any key to stop the script. For example:
- Copy code
- fg
- <press any key>
- I hope this helps
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement