[ILUGC] Re: How to restart a perl script if it is stopped?
- From: MohanR <mohan43u@xxxxxxxxx>
- To: ilugc@xxxxxxxxxxxxx
- Date: Mon, 25 Jul 2016 15:59:41 +0530
On Mon, 2016-07-25 at 08:57 +0530, Shrinivasan T wrote:
I have a perl script in a desktop which is doing web scrawling
when the internet connection goes down sometimes, the script tries
min. Then it dies.
If there is no restriction to run this perl script as root and if you
happen to be in a systemd based distro, this is all you want,
Description=crawler service which dont crawl google
Save the above content in /etc/systemd/system/crawler.service and
enable+start the service
# systemctl daemon-reload && systemctl enable crawler.service &&
systemctl start crawler.service
Thats it, this crawler.service will start your perl script whenever
your system connects to internet (to be specific, whenever
NetworkManager/systemd-networkd thinks that it got internet
connection). This service will also restart your perl script if it
stops cleanly (that means if the perl script exit with exit code 0).
Also, systemd will make sure crawler.service will not run if there is
no internet connection.
More information available in following manpages
ILUGC List: http://www.freelists.org/list/ilugc
ILUGC Web: http://ilugc.in/
Other related posts: