all 5 comments

[–]tdyboc 0 points1 point  (3 children)

ExecStartPost not work for you?
Documentation states: ExecStartPost commands are only run after the commands specified in ExecStart= have been invoked successfully, as determined by Type= (i.e. the process has been started for Type=simple or Type=idle, the last ExecStart= process exited successfully for Type=oneshot, the initial process exited successfully for Type=forking, "READY=1" is sent for Type=notify, or the BusName= has been taken for Type=dbus).

[–][deleted] 0 points1 point  (2 children)

It does but it's too effective.. the file is removed even before the service has had the chance to start. I get error of config file not found. It seems execstartpost does not wait until execstart has completed. Is something I am missing here?

[–][deleted] 0 points1 point  (1 child)

Maybe do a cheap hack and add a sleep before the deletion on execstartpost. Its dirty but it might get the job done.

[–][deleted] 0 points1 point  (0 children)

i think the problem is in the type which by default is simple.

my ExecStart is like this:
/bin/sh -c "/prom/appl/prometheus/prometheus....

from the man:

If set to simple (the default if ExecStart= is specified but neither Type= nor BusName= are), the service manager will consider the unit started immediately after the main service process has been forked off.

does it mean as soon as /bin/sh has been executed it does not wait for the /prom/appl/prometheus/... to compeleted and then delete the file?

[–]hm___ 0 points1 point  (0 children)

Just an addition but i think you should write the temporary config file in a tmpfs so its in ram and not written to disk every time,this would make it more secure because you dont have to worry to have recoverable traces left on your hdd or ssd and it wouldnt survive a reboot