Apologies for the length:
I posted the same post on Stack Overflow: https://stackoverflow.com/questions/69671377/attempting-to-enable-a-custom-service-in-ubuntu-18-04-minimal-returns-failed-to
On this system, I have AWS CLI2 installed, along with the supporting packages, and various generic packages like unzip and wget.
I have an AWS instance running Ubuntu 18.04 LTS Minimal (ami-006e7e4c46a45d7d7). I have a .service file (backuptos3.service) that I have created and is running on several CentOS servers. It performs a script. (Backup_To_S3.sh) There is a companion .timer file that is supposed to trigger this the .service file. (backuptos3.timer)
I have "Backup_To_S3.sh" in "/home/users/bin" with 755 permissions (which may not be the right word). The "backuptos3.service" and "backuptos3.timer" files are in "~/.config/systemd/user" with 755 permissions also. The owner here is the same as the owner of the folder.
When I run the command:
sudo systemctl enable backuptos3.service
I get the error: "Failed to enable unit: Unit file backuptos3.service does not exist."
I have not found a cogent explanation of why and what to do to fix it. Any Ideas?
I replaced the server (It's AWS after all) with a 18.04 LTS (Not minimal) but that did not fix it. I checked the release notes (on the off chance...) nothing.
This did not seem to fit: https://stackoverflow.com/questions/53297867/enable-docker-services-in-ubuntu-18-04
These two seemed to fit, but I don't understand what was going on: https://github.com/nix-community/lorri/issues/68 and https://github.com/abraunegg/onedrive/issues/250
I also saw this one: Failed to start gunicorn.service: Unit gunicorn.service not found. Ubunto 18.04. The problem is that the suggested answer is where my problem begins.
I used https://www.linux.com/training-tutorials/systemd-timers-two-use-cases-0/ to build the files initially.
I have included the .service and .timer files below.
# backuptos3.service
[Unit]
Description= Uploads Backups to AWS S3
Documentation= ""
[Service]
Type= simple
User= ubuntu
ExecStart= /home/ubuntu/bin/Backup_To_S3.sh
TimeoutStopSec= 21600 # 6 hours
[Install]
WantedBy= multi-user.target
and
# backuptos3.timer
[Unit]
Description=backuptos3
[Timer]
Unit=backuptos3.service
OnCalendar=*-*-* 02:30:00
Persistent=true
[Install]
WantedBy=basic.target
UPDATE: After a suggestion from Doug Smythies, I did a little more searching on enabling user vs root services. Found a stack overflow article (https://stackoverflow.com/questions/66534369/error-failed-to-enable-unit-invalid-argument) that discussed the Argument invalid issue. This led to another article (https://stackoverflow.com/questions/48177558/what-does-failed-to-execute-operation-invalid-argument-mean-when-running-syst) that had a systems analyzer sudo systemd-analyze verify yourname.service
I ran this and came up with:
Configuration file /etc/systemd/system/./backuptos3.service is marked executable. Please remove executable permission bits.
Proceeding anyway. backuptos3.service: Service has more than one
ExecStart= setting, which is only allowed for Type=oneshot services.
Refusing. backuptos3.service: Failed to create
backuptos3.service/start: Unit backuptos3.service is not loaded
properly: Invalid argument. backuptos3.service: Command
/home/centos/bin/PDFS3Uploader.sh is not executable: No such file or
directory Attempted to remove disk file system, and we can't allow
that.
I will be working through this block to see if I can make progress.