I use MX Linux and want regular snapshots that I can use to make a bootable USB. Can this run unattended without asking for a sudo password? I don't know how to write the script yet.
Can I automate MX Snapshot with a cron job?
Answers
Yes, an unattended scheduled job can run as root, so it won't need to prompt for a sudo password. A root cron job is simpler than putting a password in a script.
The missing piece is how your installed version of MX Snapshot supports unattended operation. Check its help and documentation for command-line options first. A graphical workflow that waits for clicks won't work just because cron launches it. Test the snapshot command manually as root before scheduling it, and check where it saves the output and whether there's enough free space.
Creating a snapshot and writing it to a USB stick are separate steps. Make sure you know which step your command performs before automating anything that writes to a device.
Reply to this answer
Another option is to allow a specific backup command through sudo without a password, then schedule it from your user account. That needs a carefully scoped sudoers rule, though. A broad passwordless rule gives anything running as your user a lot more power.
For someone new to scripting, I'd start by finding the supported command and getting it working manually. Once you have that, it will be much easier to ask for help turning it into a scheduled job.
Reply to this answer
Add your answer
Answers are reviewed before publication.
v274+pktdecode_5:
Also check the output and any error messages from the scheduled job. An unattended run isn't much use if it fails quietly.