• We had to restore from a backup today after a failed software update. Backup was from 0000 EDT and restored it at 0800 EDT so we lost about 8hrs. Today is 07/20/2024. More info here.

Running a script at startup


New Member
May 23, 2022
Reaction score
I have a script to mount 2 network drives that work perfectly from the terminal using "sudo sh MntPD". This is the content of the MntPD file:

sudo mount.cifs // /media/plexdata -o vers=2.0,username=USERNAME,password=PASSWORD,noperm
sudo mount.cifs // /media/Drobo5n2 -o vers=2.0,username=USERNAME,password=PASSWORD,noperm
exit 0

I have tried using crontab, systemd and rc.local to have this script run automatically at startup with no success. I have modified startup so that no password is required for the sudo command. How can I get this script to run automatically?

Instead of putting sudo in each command in the script..
have you tried simply running the entire script with sudo. Or perhaps in root's crontab.
Why not just put that in /etc/fstab without the mount and the sudo commands?
Last edited:
Are the drives auto mounted on start up or not, if so why not.
If you can find the drives UUID using Gparted or partitionmanager then
put a line for each drive into your /etc/fstab file.
Exchange your drive UUID and mount path, the below mounts the
drive HDDL2 on /media , note I have ntfs as the file type, change that to
your file type. the 1000 gives access to owner root with full control.

UUID=3FAC12281A1EAB69  /media/HDDL2  ntfs uid=1000,gid=1000  0  2
If there is a posabillity you may forget to plug the drive in like with a USB
connected drive, you should add the nofail flag in the line too, otherwise boot
will take a long time and in a lot of cases not boot at all.
nofail tells the system its not required, and boot will proceed without fail.
Here is an example below.
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
the 4th column is where you change your mount options. In your case, change defaults to defaults,nofail

UUID=123ec4fd-54e2-4590-8a4b-da43630efd72 /media/Data1 ext4 defaults,nofail 0

UUID=3FAC12281A1EAB69  /media/HDDL2  ntfs defaults,nofail uid=1000,gid=1000  0  2
Last edited by a moderator: