Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux command to check if a shell script is running or not

Tags:

linux

shell

What is the linux command to find if a process say aa.sh is running or not. ps command does not seem to work and it does not show the shell script names.

Please advise.

like image 231
Manikandan Kannan Avatar asked May 30 '13 04:05

Manikandan Kannan


People also ask

How do I know if shell script is running?

Create PID file sh. pid # Add check for existence of mypidfile if [ -f $mypidfile ]; then echo "script is already running" exit fi # Ensure PID file is removed on program exit. trap "rm -f -- '$mypidfile'" EXIT # Create a file with current PID to indicate that process is running.

How do I know if a script is running in the background Linux?

You can list running processes using the ps command (ps means process status). The ps command displays your currently running processes in real-time.

How can I test shell script without running it?

Use the "-n" option ... bash will check the syntactical validity of a script without running it.


1 Answers

Check this

ps aux | grep "aa.sh" 
like image 90
krizna Avatar answered Sep 24 '22 14:09

krizna