Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Create a Shell Script:
For example, you can create a script named check_process.sh with the following content:
#!/bin/bash
process_name="your_process_name"
if ! pgrep -x "$process_name" > /dev/null; then
echo "$process_name is not running. Starting it now..."
# Start your process here, for example:
# /path/to/your/process &
else
echo "$process_name is already running."
fi
Make the Script Executable:
chmod +x check_process.sh
Create a systemd Service Unit:
Create a file, e.g., check_process.service, in the /etc/systemd/system/ directory:
[Unit]
Description=Check and start your process if not running
[Service]
ExecStart=/path/to/your/check_process.sh
Restart=always
[Install]
WantedBy=multi-user.target
Reload systemd
sudo systemctl daemon-reload
Start and Enable the Service
sudo systemctl start check_process
sudo systemctl enable check_process
Check the Status:
sudo systemctl status check_process -
glowFX831yHaha, 15 years ago we had this too in my previous company. I think it was called check.sh and did exactly that. :'-D
-
@helloworld I love when people give real answers instead of forwarding to Google.
@netikras I called you a nerd but you were really cool -
@retoor I don't in fact know how to do it at this moment. But a few google searches and I will. Both googling and digesting google information are skills. Better to acquire those skills when people are available than when they are not. If someone posts a "this is what I tried" instead. I will help them with what they posted. But they must make an effort.
-
@retoor This is a classic example where chatgpt can provide an accurate and well explained solution. Quicker than google and better than stack. That’s all I did. Chatgpt is another tool in your toolbox, you’re a fool if you dismiss it.
-
@Demolishun I already searched for this on Google however the reason I'm asking is just to get what other are using and get their approach, to make it simple you have a problem and you asked your friend what should I do? He tells you ask google... you know what google is and you already got your solution but you are just asking to confirm that the solution you got is the best one
-
@helloworld right, i did that too, chatgpt suggested to use systemd and supervisor
Related Rants
-
gururaju56*Now that's what I call a Hacker* MOTHER OF ALL AUTOMATIONS This seems a long post. but you will definitely ...
-
linuxxx70This guy at my last internship. A windows fanboy to the fucking max! He was saying how he'd never use anythi...
-
creedasaurus62Another dev on my team just got a new machine. Before he came in today I made two separate USB installers and ...
Guys, please don't scream at me :D
i need a tool to be installed on ubuntu that check if a specific process is running or not, if not then it starts it automatically
question
linux