How can you get the script name in the BSD process accounting file?

I am trying to write a program to handle a BSD style accounting file under Linux (/ var / account / pacct).

When we run the script with ./script_name

or bash script_name

, the process account actually writes out the command bash

. Presumably because the actual program is doing the job.

What we would like to see is the team script_name

. Does anyone know of a way to get the script name written to the accounting file and not the bash executable?

+1


source to share


1 answer


Linux: Eternal Bash Story with Snoopy .

Edit : As an alternative to a hack, you can periodically runps -eo args

Edit by questioner (so I can accept the answer from the only SO'er that helped :-):



I found that if you actually added " #!bin/bash

" to the file , it started showing up in a pacct named script ( tst

) instead of interpreter ( bash

).

My script was stripped of the hash token initially, and it could be that it bash

had to re-execute itself or something. Anyway, this has now been fixed.

+2


source







All Articles