sudo crontab -e
edits root's crontab right? When you say you have $HOME/.awssecret, what is $HOME? root's home or yours?
You might want to think about using /etc/cron.d, you can additionally add the name of the user to execute the script as in these files (e.g. caution: slightly different syntax for the scripts)
Edit (answering your question in the comment):
Create a file /etc/cron.d/myEc2Crontab
make it contain:
SHELL=/bin/sh
PATH=whatever you need as your path
12 18 4 2 * root ec2-consistent-snapshot --mysql --xfs-filesystem /vol vol-xxxxxxx >>/mnt/backup.log 2>&1
note the added 'root' just after the time specification, prior to your command. This specifies the user the command runs as.
Times change and so do best practices.
The current best way to do this is to run systemctl edit myservice
, which will create an override file for you or let you edit an existing one.
In normal installations this will create a directory /etc/systemd/system/myservice.service.d
, and inside that directory create a file whose name ends in .conf
(typically, override.conf
), and in this file you can add to or override any part of the unit shipped by the distribution.
For instance, in a file /etc/systemd/system/myservice.service.d/myenv.conf
:
[Service]
Environment="SECRET=pGNqduRFkB4K9C2vijOmUDa2kPtUhArN"
Environment="ANOTHER_SECRET=JP8YLOc2bsNlrGuD6LVTq7L36obpjzxd"
Also note that if the directory exists and is empty, your service will be disabled! If you don't intend to put something in the directory, ensure that it does not exist.
For reference, the old way was:
The recommended way to do this is to create a file /etc/sysconfig/myservice
which contains your variables, and then load them with EnvironmentFile
.
For complete details, see Fedora's documentation on how to write a systemd script.
Best Answer
I ended up with adding these lines to the startup script:
Looks like the
containerd
service was started: