Closed Ao1Pointblank closed 1 year ago
hi,
with the current makefile a2ln is installed into ~/.local/bin/a2ln
(on ubuntu), which is not in the default PATH
and therefore can probably not be found by a cronjob (but interactive bash can find it due to your ~/.bashrc
).
You could try to replace a2ln
with /home/USERNAME/.local/bin/a2ln
(or wherever it is installed according to whereis a2ln
) in your crontab.
it might also help with debugging to see the log (/var/log/cron.log
).
Since you are using mint i assume you are also using systemd. in which case a service would probably be a good alternative to a crontab:
~/.config/systemd/user/a2ln.service
:
[Unit]
Description=Android 2 Linux Notifications Server
[Service]
ExecStart=/home/USERNAME/.local/bin/a2ln 46352 --pairing-port 46351 --title-format "{app} | {title}" --command 'if [ -f ~/.sounds/a2ln/{app}.mp3 ]; then play -Gq --norm=0 ~/.sounds/a2ln/{app}.mp3; else play -Gq --norm=0 ~/.sounds/a2ln/default.mp3; fi'
Restart=always
[Install]
WantedBy=graphical.target
and then run systemctl --user enable a2ln
to enable autostart and systemctl --user start a2ln
to start it and then systemctl --user status a2ln
to check if it started (and systemctl --user restart a2ln
to restart it).
This is perfect for me!! I also added the line RuntimeMaxSec=20m
before Restart=always
(i don't know if the order of the lines matters) to make sure it stays working! Thank you @Jan9103 ^^
These are the contents of my crontab (crontab -e, to edit it). I know the second command at least partially works, because I do receive the notification every 20 minutes. However, the
@reboot
line does not seem to start the server, according to my system monitor.After some more testing, I determined a2ln can be launched from the command prompt button combo (alt+f2 on Mint by default)
I rewrote the kill/restart script so it isn't just a one-liner anymore, and tried running it from the command prompt.
It kills the server just fine, but doesn't restart it. The notification is also not produced. All these commands can be run from the command prompt individually, but not together when executed as one-liner or from a file, even when prefixed with 'bash -c', within the command prompt. I am using the command prompt as a testbed for command execution without GUI, since it is easier than restarting my computer over and over to test the
@reboot
function in crontab.Oh, and when the .sh file is run in terminal, it simply kills any running a2ln server then closes with signal 15 (SIGTERM)