Re: [systemd-devel] empty a directory in service file as ExecStartPre
On Sat, Jan 2, 2016 at 1:57 PM, Reindl Harald wrote: > > > Am 02.01.2016 um 13:43 schrieb arnaud gaboury: >> >> ExecStartPre=/usr/bin/rm -f ${REPORTDIR}/ > > > ExecStartPre=/usr/local/scripts/emptydir.sh $REPORTDIR Thank you, but I would prefer to avoid any external script. I finally found the correct way, as I had to remove everything (lucky all are files) except the one sub directory: ExecStartPre=/usr/bin/find ${REPORTDIR} -mindepth 1 -type f -delete > > > ___ > systemd-devel mailing list > systemd-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/systemd-devel > -- google.com/+arnaudgabourygabx ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] empty a directory in service file as ExecStartPre
Am 02.01.2016 um 13:43 schrieb arnaud gaboury: ExecStartPre=/usr/bin/rm -f ${REPORTDIR}/ ExecStartPre=/usr/local/scripts/emptydir.sh $REPORTDIR signature.asc Description: OpenPGP digital signature ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] empty a directory in service file as ExecStartPre
On Sat, Jan 2, 2016 at 1:08 PM, Mantas Mikulėnas wrote: > ExecStart does not go through a shell, so it won't expand wildcards. OK. I understand now. > > Try running 'find /dir -mindepth 1 -delete', that also cleans up dotdirs. In my case, there is one more hurdle. Will post elsewhere as it is OT in this list. Thank you for your help. > > Alternatively 'sh -c "rm .../*" to handle wildcards. > > > On Sat, Jan 2, 2016, 13:39 arnaud gaboury 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 -- google.com/+arnaudgabourygabx ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] empty a directory in service file as ExecStartPre
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 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
[systemd-devel] empty a directory in service file as ExecStartPre
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