M
M
muhasa2019-09-24 14:22:56
linux
muhasa, 2019-09-24 14:22:56

How to run an eternal process in Linux?

#!/bin/bash
while true;
do /usr/bin/php7.2 index.php;
sleep 1;
done

Guys, with this code I'm polling some api, which allows you to send requests once a second. How can I run this process in the background in Linux "forever", so that when I close the terminal window with ssh, it still works in the background. And then how to slow it down if necessary?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
S
Sergey Sokolov, 2019-09-24
@muhasa

nohup parser.sh &

M
metajiji, 2019-09-25
@metajiji

systemd please.

S
Sanes, 2019-09-24
@Sanes

  1. About the ampersand
  2. About screen

R
Roman Roldugin, 2019-09-25
@ChaosTeory

use supervisor, if the script crashes then the supervisor will pick it up

P
pfg21, 2019-09-24
@pfg21

if this is meant forever, then write a daemon script for your init system and let it work under its supervision.
start/stop/status through the initialization system.

K
kberdnikov, 2019-09-25
@kberdnikov

Fork bomb

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question