How can I automate MX Snapshot from cron without entering a sudo password?

0
0
Asked By BlueMango47 On

I use MX Linux for professional systems that need regular backups. I'd like to create a Bash script that runs MX Snapshot automatically on a schedule and produces a live, bootable USB drive without requiring me to enter a sudo password each time. I'm not experienced with scripting, so I'm looking for guidance on whether this is possible and how to set it up safely.

2 Answers

Answered By QuietHarbor8 On

Yes, this is possible, but the snapshot operation needs root privileges. The safer approach is usually to run the scheduled job as root rather than placing a broad password-free sudo rule in your account. If sudo must be used, create a narrowly scoped rule in a file under /etc/sudoers.d/ that permits only the specific snapshot command with NOPASSWD. Test the command manually first, then account for cron’s limited environment and use absolute paths in the script.

BlueMango47 -

Thanks for explaining. I’m not a techie and can’t write the script myself, so I was hoping for an example or a reference showing how to build it.

Answered By CedarPixel3 On

A cron job can launch a Bash script at the desired interval, but creating a bootable USB involves more than just copying files and may require a target device that is always connected and identified reliably. Make sure the script checks the correct destination before writing, since using the wrong device path could erase another disk. You’ll also need to decide how to handle logs, failures, and whether the USB should be unmounted safely when the job finishes.

BlueMango47 -

I’d appreciate a tutorial or library reference for scripting this, especially since I don’t have enough coding experience to start from scratch.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.