ExecStart does not go through a shell, so it won't expand wildcards. Try running 'find /dir -mindepth 1 -delete', that also cleans up dotdirs.
Alternatively 'sh -c "rm .../*" to handle wildcards. On Sat, Jan 2, 2016, 13:39 arnaud gaboury <arnaud.gabo...@gmail.com> wrote: > 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 > _______________________________________________ > systemd-devel mailing list > systemd-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/systemd-devel >
_______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel