0

I have a nginx that depends on a mounted drive.

My nginx.service has an entry with the RequiresMountsFor in the service unit like this:

[Unit]
RequiresMountsFor=/media/bar

But looks like it is still booting ahead of the mount point.

My mount cmd looks like this and on cron jobs @reboot:

mount -o bg,nolock,noac,actimeo=0 192.168.1.5:/foo/bar /media/bar

I'm not finding where it is going wrong. Here is config showing systemctl show nginx.service

...
Before=multi-user.target shutdown.target
After=foo-bar.mount sysinit.target network.target -.mount system.slice basic.target systemd-journald.socket
RequiresMountsFor=/media/bar
...

1 Answers1

0

If you need to run specifically after cron, you may be able to add

Requires=cronie.service

in your unit file, which will wait for crond to start before trying the nginx service.

You may also have some luck moving the mount to /etc/fstab instead of as a cron. systemd automatically picks up mounts from there and creates appropriate mount files.