Paul_griff
Posts: 45
Joined: Sat Jul 21, 2012 9:23 pm

How do I check if a program is running

Sat Aug 04, 2012 8:25 am

Please could someone give me a complete guide to checking if a program (no-ip) is running, I am trying to get it to run automatically at startup and need to be able to check
Apologies for all the stupid questions!

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: How do I check if a program is running

Sat Aug 04, 2012 8:36 am

The command ps lists all running programs that you started from the commandline. Add "axg" to list all the programs including all those owned by the system.

That's a huge list and difficult to search by eye, so filter it by the name of the program you are looking for with the "grep" command, using the pipe character to pass the output of one command to the input of the other:

Code: Select all

ps axg | grep no-ip
That command itself will of course by listed, since it has that text in it. If the program is running it will also be listed.

User avatar
rpdom
Posts: 14688
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: How do I check if a program is running

Sat Aug 04, 2012 8:54 am

The pidof command is useful in this case.

Code: Select all

pidof no-ip
should return the process ID of the no-ip program, or nothing at all if it isn't running.

Also, when using ps you can prevent the ps command showing by enclosing one of the letters of the name in square brachets

Code: Select all

ps axg | grep [n]o-ip

KenT
Posts: 758
Joined: Tue Jan 24, 2012 9:30 am
Location: Hertfordshire, UK
Contact: Website

Re: How do I check if a program is running

Sat Aug 04, 2012 9:10 am

Tor interactive use top shows a list of running process, top -upi shows just user pi processes
Pi Presents - A toolkit to produce multi-media interactive display applications for museums, visitor centres, and more
Download from http://pipresents.wordpress.com

nadir
Posts: 112
Joined: Sun Jun 10, 2012 5:45 am

Re: How do I check if a program is running

Sun Aug 05, 2012 7:56 pm

rpdom wrote:The pidof command is useful in this case.

Code: Select all

pidof no-ip
should return the process ID of the no-ip program, or nothing at all if it isn't running.

Also, when using ps you can prevent the ps command showing by enclosing one of the letters of the name in square brachets

Code: Select all

ps axg | grep [n]o-ip
Strange enough i just ran into the "grep [p]attern" trick myself:
http://ithaca.arpinum.org/2012/07/18/grep-trimming.html

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: How do I check if a program is running

Sun Aug 05, 2012 9:08 pm

NB: It might have to be "ps -axg", since I tried it without the minus and it didn't work, although last time I checked the manual I thought it should.

User avatar
M.M
Posts: 107
Joined: Fri Aug 03, 2012 7:40 am
Location: Hamburg, GER

Re: How do I check if a program is running

Mon Aug 06, 2012 8:16 am

Hello rurwin,

your initial assumption was correct: it's "ps axg" without a minus. It may depend on the distro though. In the Debian world it certainly works without the minus.

Regards
"If people read the FAQs the Qs wouldn't be A F, would they?"

User avatar
jojopi
Posts: 3078
Joined: Tue Oct 11, 2011 8:38 pm

Re: How do I check if a program is running

Mon Aug 06, 2012 10:24 am

procps accepts both POSIX and BSD options. POSIX options should have a hyphen, and BSD options should not. The canonical "show all processes for all users" commands are respectively "ps -ef" and "ps axu".

mikebougie
Posts: 4
Joined: Thu Apr 06, 2017 9:53 am

Re: How do I check if a program is running

Thu Apr 06, 2017 9:55 am

Code: Select all

sudo /usr/local/bin/noip2 -S
works for me.

gumby617
Posts: 1
Joined: Wed Oct 11, 2017 8:30 pm

Re: How do I check if a program is running

Wed Oct 11, 2017 8:35 pm

If the config file states to update every 20 mins does the process need to be running at all times? When I run the below commands the no-ip2 "program" is not running at startup, however my config file states to update every 20 minutes. Also I tried to nano the config file to add another host entry but it was encrypted or at least the letter combo looked like that and I decided not to edit it.

W. H. Heydt
Posts: 10565
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: How do I check if a program is running

Thu Oct 12, 2017 5:13 pm

Since the OP knows what program he wants to check, he could use...

ps -C <programname>

User avatar
B.Goode
Posts: 8021
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: How do I check if a program is running

Thu Oct 12, 2017 5:43 pm

W. H. Heydt wrote:
Thu Oct 12, 2017 5:13 pm
Since the OP knows what program he wants to check, he could use...

ps -C <programname>
I'm told that old threads should not die because someone might find the content useful.

But I think this one has earned its rest: that program will have been running for 5 years, and the OP hasn't been logged in to the forum for nearly 3 of those years.

Return to “Beginners”