[systemd-devel] empty a directory in service file as ExecStartPre
arnaud gaboury
arnaud.gaboury at gmail.com
Sat Jan 2 03:39:06 PST 2016
I can't manage to empty a directory as a Exec in a service file. Here is part:
---------------------------------------------------------------
[Service]
User=postgres
Environment=REPORTDIR=/storage/psqlReport
ExecStartPre=/usr/bin/rm -f ${REPORTDIR}/*
ExecStart=MyCommand
--------------------------------------------------
$ journalctl -xe -l
-------------------------------
-- Unit pgcluu_collectd.service has begun starting up.
Jan 02 12:34:02 poppy pgcluu_collectd[21593]: *** pgcluu_collectd v2.4
(pid:21593) started at Sat Jan 2 12:34:02 2016
Jan 02 12:34:02 poppy pgcluu_collectd[21593]: Type Ctrl+c to quit.
Jan 02 12:34:02 poppy pgcluu[21594]: FATAL: output directory
/storage/psqlReport is not empty. at /usr/bin/pgcluu line 1033.
Jan 02 12:34:02 poppy systemd[1]: pgcluu_collectd.service: Control
process exited, code=exited status=2
-------------------------------------------------
Running manually the rm command as user postgres empty the directory,
but when in service file, the directory is still full. I see it as
ExecStart=MyCommand complains the directory is full and service exits
with an error.
User postgres has of course rw access to directory content.
No any kind of interactive prompt when running rm.
If I start the service with an empty /storage/psqlReport, service success.
What am I missing? Is there a better way to empty the directory before
running my command ? The service will be timered, so can't empty
manually.
Thank you for help.
--
google.com/+arnaudgabourygabx
More information about the systemd-devel
mailing list