fstab mounting time
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
1
down vote
favorite
I'm working on a script that is supposed to execute on startup, but the problem is that the script requires some files that are on a shared drive that is automatically mounted via fstab and at the time of it's execution the drive isn't mounted yet.
I've tried using cron @reboot and init.d route but they both execute too early. I also considered adding mount -a
to the script, but I would rather avoid having to sudo
it. For now I just added a delay to make it work, but that feels a bit hacky.
Is there a way to ensure that a startup script runs after fstab has been processed? Or force the mounts to be processed without using sudo
?
ubuntu cron fstab sysvinit
add a comment |Â
up vote
1
down vote
favorite
I'm working on a script that is supposed to execute on startup, but the problem is that the script requires some files that are on a shared drive that is automatically mounted via fstab and at the time of it's execution the drive isn't mounted yet.
I've tried using cron @reboot and init.d route but they both execute too early. I also considered adding mount -a
to the script, but I would rather avoid having to sudo
it. For now I just added a delay to make it work, but that feels a bit hacky.
Is there a way to ensure that a startup script runs after fstab has been processed? Or force the mounts to be processed without using sudo
?
ubuntu cron fstab sysvinit
You are using Ubuntu, an operating system that has been a systemd operating system since 2016 and was an Upstart operating system for a decade before that, since 2006. van Smoorenburgrc
scripts have not been a "route" for a long time on your operating system. The systemd version of this question has already been asked and answered here at unix.stackexchange.com/questions/246935 .
â JdeBP
Jul 19 at 15:38
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm working on a script that is supposed to execute on startup, but the problem is that the script requires some files that are on a shared drive that is automatically mounted via fstab and at the time of it's execution the drive isn't mounted yet.
I've tried using cron @reboot and init.d route but they both execute too early. I also considered adding mount -a
to the script, but I would rather avoid having to sudo
it. For now I just added a delay to make it work, but that feels a bit hacky.
Is there a way to ensure that a startup script runs after fstab has been processed? Or force the mounts to be processed without using sudo
?
ubuntu cron fstab sysvinit
I'm working on a script that is supposed to execute on startup, but the problem is that the script requires some files that are on a shared drive that is automatically mounted via fstab and at the time of it's execution the drive isn't mounted yet.
I've tried using cron @reboot and init.d route but they both execute too early. I also considered adding mount -a
to the script, but I would rather avoid having to sudo
it. For now I just added a delay to make it work, but that feels a bit hacky.
Is there a way to ensure that a startup script runs after fstab has been processed? Or force the mounts to be processed without using sudo
?
ubuntu cron fstab sysvinit
asked Jul 19 at 15:29
Maxim
21715
21715
You are using Ubuntu, an operating system that has been a systemd operating system since 2016 and was an Upstart operating system for a decade before that, since 2006. van Smoorenburgrc
scripts have not been a "route" for a long time on your operating system. The systemd version of this question has already been asked and answered here at unix.stackexchange.com/questions/246935 .
â JdeBP
Jul 19 at 15:38
add a comment |Â
You are using Ubuntu, an operating system that has been a systemd operating system since 2016 and was an Upstart operating system for a decade before that, since 2006. van Smoorenburgrc
scripts have not been a "route" for a long time on your operating system. The systemd version of this question has already been asked and answered here at unix.stackexchange.com/questions/246935 .
â JdeBP
Jul 19 at 15:38
You are using Ubuntu, an operating system that has been a systemd operating system since 2016 and was an Upstart operating system for a decade before that, since 2006. van Smoorenburg
rc
scripts have not been a "route" for a long time on your operating system. The systemd version of this question has already been asked and answered here at unix.stackexchange.com/questions/246935 .â JdeBP
Jul 19 at 15:38
You are using Ubuntu, an operating system that has been a systemd operating system since 2016 and was an Upstart operating system for a decade before that, since 2006. van Smoorenburg
rc
scripts have not been a "route" for a long time on your operating system. The systemd version of this question has already been asked and answered here at unix.stackexchange.com/questions/246935 .â JdeBP
Jul 19 at 15:38
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
For that you have to run your script as a systemd unit (assuming you have systemd) where you could define dependency...
If you want to stick with cron @reboot (what sounds the simple choice) you have to make your script a bit smarter (or start cron after fs mounts... what change I wouldn't suggest). Instead of a simple delay, you can check if the required filesystem is mounted (in bash):
while ! mount | awk 'print $3' | grep -qx /the/mountpoint; do
sleep 1
done
Or you can check if the file is there what you need:
while ! [ -f /that/file ] ; do
sleep 1
done
add a comment |Â
up vote
0
down vote
I'm going to assume you're on a relatively new Linux distro, so you may need to check systemd
manual since SysV
is no longer being used in the default distro installations and that is most probably your problem. systemd
allows for startup dependencies where you specify what scripts run before others.
Check the next link
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
For that you have to run your script as a systemd unit (assuming you have systemd) where you could define dependency...
If you want to stick with cron @reboot (what sounds the simple choice) you have to make your script a bit smarter (or start cron after fs mounts... what change I wouldn't suggest). Instead of a simple delay, you can check if the required filesystem is mounted (in bash):
while ! mount | awk 'print $3' | grep -qx /the/mountpoint; do
sleep 1
done
Or you can check if the file is there what you need:
while ! [ -f /that/file ] ; do
sleep 1
done
add a comment |Â
up vote
2
down vote
accepted
For that you have to run your script as a systemd unit (assuming you have systemd) where you could define dependency...
If you want to stick with cron @reboot (what sounds the simple choice) you have to make your script a bit smarter (or start cron after fs mounts... what change I wouldn't suggest). Instead of a simple delay, you can check if the required filesystem is mounted (in bash):
while ! mount | awk 'print $3' | grep -qx /the/mountpoint; do
sleep 1
done
Or you can check if the file is there what you need:
while ! [ -f /that/file ] ; do
sleep 1
done
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
For that you have to run your script as a systemd unit (assuming you have systemd) where you could define dependency...
If you want to stick with cron @reboot (what sounds the simple choice) you have to make your script a bit smarter (or start cron after fs mounts... what change I wouldn't suggest). Instead of a simple delay, you can check if the required filesystem is mounted (in bash):
while ! mount | awk 'print $3' | grep -qx /the/mountpoint; do
sleep 1
done
Or you can check if the file is there what you need:
while ! [ -f /that/file ] ; do
sleep 1
done
For that you have to run your script as a systemd unit (assuming you have systemd) where you could define dependency...
If you want to stick with cron @reboot (what sounds the simple choice) you have to make your script a bit smarter (or start cron after fs mounts... what change I wouldn't suggest). Instead of a simple delay, you can check if the required filesystem is mounted (in bash):
while ! mount | awk 'print $3' | grep -qx /the/mountpoint; do
sleep 1
done
Or you can check if the file is there what you need:
while ! [ -f /that/file ] ; do
sleep 1
done
answered Jul 19 at 15:43
redseven
1876
1876
add a comment |Â
add a comment |Â
up vote
0
down vote
I'm going to assume you're on a relatively new Linux distro, so you may need to check systemd
manual since SysV
is no longer being used in the default distro installations and that is most probably your problem. systemd
allows for startup dependencies where you specify what scripts run before others.
Check the next link
add a comment |Â
up vote
0
down vote
I'm going to assume you're on a relatively new Linux distro, so you may need to check systemd
manual since SysV
is no longer being used in the default distro installations and that is most probably your problem. systemd
allows for startup dependencies where you specify what scripts run before others.
Check the next link
add a comment |Â
up vote
0
down vote
up vote
0
down vote
I'm going to assume you're on a relatively new Linux distro, so you may need to check systemd
manual since SysV
is no longer being used in the default distro installations and that is most probably your problem. systemd
allows for startup dependencies where you specify what scripts run before others.
Check the next link
I'm going to assume you're on a relatively new Linux distro, so you may need to check systemd
manual since SysV
is no longer being used in the default distro installations and that is most probably your problem. systemd
allows for startup dependencies where you specify what scripts run before others.
Check the next link
answered Jul 19 at 15:39
YoMismo
2,8831619
2,8831619
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f457247%2ffstab-mounting-time%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
You are using Ubuntu, an operating system that has been a systemd operating system since 2016 and was an Upstart operating system for a decade before that, since 2006. van Smoorenburg
rc
scripts have not been a "route" for a long time on your operating system. The systemd version of this question has already been asked and answered here at unix.stackexchange.com/questions/246935 .â JdeBP
Jul 19 at 15:38