0

I have an init script that executes a jar file in the background, and I want to print the PID to a file. Using the following immediately after the execute command the file is created, but it is empty.

start process & \
echo $! >/var/run/foo.pid

Why might this be? Thanks

5
  • 3
    Your question title says $1 but your question body says $!. Which is it? Commented Mar 3, 2018 at 2:22
  • Which shell is used to execute the "init script"? Commented Mar 3, 2018 at 3:45
  • 1) what user runs the script? 2) does it work if you run the script as that user, but from the command line? 3) is something else truncating the file? 4) did the start process thing actually run or did you get a "no such file or directory" error? (i.e. is PATH correctly set in the script?) Commented Mar 3, 2018 at 7:34
  • Title had typo, I've corrected that. Commented Mar 5, 2018 at 17:25
  • Using Bash shell, script being run as root, but jar file being executed as AD generic account specified in script, jar file runs as expected with no error printed, path is correct as the file is successfully created but blank. Commented Mar 5, 2018 at 17:31

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.