[SATLUG] cron sudo task

Henry Pugsley henry.pugsley at gmail.com
Tue Jan 25 12:52:40 CST 2011

On Tue, Jan 25, 2011 at 11:08 AM, Richard Suberg <rsuberg at satx.rr.com>wrote:

> Hash: SHA256
> I have a task that is scheduled with cron and it runs the task,
> however, since it mounts a remote ftp server into the filesystem (and
> I haven't figured out the parameters for fstab) for it to actually be
> productive and mount it needs to be run root. I can manually run the
> task as sudo and it completes ok, but how can I cron the sudo run of
> the very same script without needing a password? I know running an ftp
> update script (or any script) as root is not the best security
> practice, but it is the only way I have found to accomplish this.
> Unless someone has a better suggestion, the process involved is:
> 1- mount ftp server into filesystem
> 2- cp -uRv location from (1) into a folder on my computer
> 3- umount remote ftp server.
> Currently I use fuse for mounting, and I do not have control over what
> programs are loaded on the remote server, I just need to update my
> documentation based on what they update.  Any ideas?
> Richard
> - --
> Thunderbird Portable...it goes with me!
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> pJoJjPaPlLaKKP2VN0QA/3JP8Xnryb8xvkk0fSvWppp/Obz3ey5r7eyakNynSHix
> =yX0w
Personally I would simply use an FTP client that supports scripted transfers
or mirroring remote folders .. lftp and ncftp can both do this.  If you have
SSH access and rsync is available on the remote server, that would be an
even better option (compression, restarting, etc). You won't have to worry
about special permissions or the mount failing and causing the whole process
to bomb.  Failing that, my next options would be:

1) Figuring out fstab and allowing the user running the script to mount the
2) Using a sudoers entry to allow that user to run a script that will
mount/unmount the filesystem (last resort)


More information about the SATLUG mailing list