A very common use of shell scripts that you write is to automate work. If you need to run
the command by hand each time, it often defeats the intent of the automation. Therefore,
it is also very common that commands are started from cron.
As Murphy's Law would have it, sometimes something will prevent the script from
ending. However, each time cron starts, a new process is
started, so you end up with dozens, if not hundreds of processes. Depending on
the script, this could have a dramatic effect on the performance of your system.
The solution is to make sure that the process can only start once, or if it is
already running, you want to stop any previous instances.
So, the first question is how to figure out what processes are running, which is
something we go into details about in another section. In
short, you can use the ps command to see what processes are running:
Note that when you run this command, it will also appear in the process table.
Since your process name is an argument to the grep command, grep ends up finding