You are not logged in.
trying to run a script 3 minutes after startup
acording to journal the timer starts fine but systemctl reports:
ntpd_packages_backintime.service loaded failed failed ntpd, packages and backintimethe timer:
[studio@localhost ~]$ cat /etc/systemd/system/ntpd_packages_backintime.timer
[Timer]
OnStartupSec=180
[Install]
WantedBy=multi-user.targetthe service
[studio@localhost ~]$ cat /etc/systemd/system/ntpd_packages_backintime.service
[Unit]
Description=ntpd, packages and backintime
[Service]
ExecStart=/usr/bin/script_ntpd_packages_backintime
[Install]
WantedBy=multi-user.target the script
[studio@localhost ~]$ cat /usr/bin/script_ntpd_packages_backintime
#!/bin/sh
ntpd -q && hwclock -w
pacman -Qqe | grep -vx "$(pacman -Qqm)" > /home/backup/Packages
pacman -Qqm > /home/backup/Packages.aur
/usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /usr/bin/backintime --backup-jobI'm not very into all this stuff, so if there is an obvious error, please be so kind to tell me.
Offline
It is better to create a service file for every single task you try to achieve instead of appending all commands to one script.
You can read more about how to write your service files here .
Have a look at this option:
Type=oneshot: This is useful for scripts that do a single job and then exit. You may want to set RemainAfterExit= as well so that systemd still considers the service as active after the process has exited.
pacman -Qqe | grep -vx "$(pacman -Qqm)" > /home/backup/Packages
pacman -Qqm > /home/backup/Packages.aur
Create a seperate script and service file for this.
Also write a seperate service for adjusting the time.
/usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /usr/bin/backintime --backup-job
Backup jobs can be done by cron, too. It makes sense to backup more frequently, especially if you do not reboot every day.
Offline
It is better to create a service file for every single task you try to achieve instead of appending all commands to one script.
You can read more about how to write your service files here .
Have a look at this option:wiki wrote:Type=oneshot: This is useful for scripts that do a single job and then exit. You may want to set RemainAfterExit= as well so that systemd still considers the service as active after the process has exited.
capoeira wrote:pacman -Qqe | grep -vx "$(pacman -Qqm)" > /home/backup/Packages
pacman -Qqm > /home/backup/Packages.aurCreate a seperate script and service file for this.
Also write a seperate service for adjusting the time.
I created seperate files but it didn't work.
but then, after looking in journal I realized that I didn't make the scripts executable. stupid me, but I must say, this is still very unhandy.
now the scripts work, though backintime gives an error message it isn't configured, It's strange because it works in terminal under root. It doesn't work in terminal with sudo though.
It is better to create a service file for every single task you try to achieve instead of appending all commands to one script.
Backup jobs can be done by cron, too. It makes sense to backup more frequently, especially if you do not reboot every day.
I'm glad I can live without cron now. I do audio work and a starting cron job can ruin a recording session. I also boot every morning, at least.
Offline
Good you could solve the problem with the scripts. I am sorry i did not understand before, why you do not want to use cron, the title "substituting cron with systemd" says all.
As systemd runs its services as root unless using the "user=" option, it is strange backintime does not work, indeed.
Offline
For the backintime problem: It might be that backintime looks for config files under $HOME somewhere. When starting a job with systemd, $HOME is not set for you. Try putting:
Environment=HOME=/rootinto the Service section of the backintime service unit so that not only will it run as root, but will also know where root's home directory is.
Offline
For the backintime problem: It might be that backintime looks for config files under $HOME somewhere. When starting a job with systemd, $HOME is not set for you. Try putting:
Environment=HOME=/rootinto the Service section of the backintime service unit so that not only will it run as root, but will also know where root's home directory is.
unfortuanatly this didn't work
the comand also didn't work with cron AFTER e uninstalled the gnome dependencies for the backintime gui. Before it worked
I'll ask on the backintime page
Offline