0

i was looking at the solution of Run cron job only if it isn't already running in order to apply it to a similar problem that I have but I cannot understand the

ps -u $USER -f | grep "[ ]$(cat ${PIDFILE})[ ]"'

It appears to be saying check the end of each line from ps for ' PIDnumber ' but when I look at my ps output the PIDnumber is in column two. I am interpreting the first $ as the regular expression check_end_of_line option.

Community
  • 1
  • 1
user1123382
  • 120
  • 6

1 Answers1

1

$(stuff) will execute "stuff" (in this case cat ${PIDFILE})

PIDFILE is assumed to be a path to a file, so the whole line is basically looking for any line in the ps output that contains the contents of the "pid file" ([ ] adds some spaces on each side of the pid so that if pid file contains '888' it wont match '8888' in the ps output)

John3136
  • 28,809
  • 4
  • 51
  • 69