LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Create a script that mounts a share, checks a file if it has not been modified in 2 or 1 days, and then unmounts it? (https://www.linuxquestions.org/questions/linux-newbie-8/create-a-script-that-mounts-a-share-checks-a-file-if-it-has-not-been-modified-in-2-or-1-days-and-then-unmounts-it-4175712180/)

rtmistler 05-19-2022 07:01 AM

Quote:

Originally Posted by riahc3 (Post 6354758)
"UNKNOWN: Mount did not work"

😂 Obviously, Im not surprised.

This goes back to, does the mount command as written in the script, work if you issue it manually from the command line.

Sorry pan64 is correct about how to check the return status of mount.

riahc3 05-19-2022 07:03 AM

Mount is working but it seems umount isnt.

pan64 05-19-2022 08:15 AM

I guess umount needs sudo too.

riahc3 05-19-2022 08:16 AM

Quote:

Originally Posted by rtmistler (Post 6354759)
This goes back to, does the mount command as written in the script, work if you issue it manually from the command line.

Yes but the user is not the same, as I stated.

pan64 05-19-2022 08:20 AM

Quote:

Originally Posted by riahc3 (Post 6354773)
Yes but the user is not the same, as I stated.

? which user is not the same?

computersavvy 05-19-2022 11:20 PM

It is quite possible to add a user (or group) to the sudoers and limit the command or commands to exactly what is specified in the sudoers file. This way you can specifically tailor allowing something to be done as root by that user but have it detailed enough to do exactly what is allowed and no more.

I would consider using that method to allow the mount and umount commands in your script to be run as that user, allowing it to mount and dismount that share, and still limit what that user can do.

Read up on the sudoers file structure and config and you will see what I mean.

The system requires that mount and umount be done as root (except for specific cases that may be done with entries in /etc/fstab, but that is another whole conversation)

riahc3 05-20-2022 02:54 AM

mount and umount work

But the script doesnt seem to be working....Hmmm

<Code removed>


And it does not enter into the conditions I set

riahc3 05-20-2022 03:04 AM

Never mind. All is working

Thanks for all the ideas and tips

computersavvy 05-20-2022 09:13 AM

Would you please post the detailed actual fix. We are presently left guessing what the solution was and nothing to tell a reader in the future how you solved the problem.


All times are GMT -5. The time now is 10:11 PM.