getssl icon indicating copy to clipboard operation
getssl copied to clipboard

On freebsd with default settings getssl script doesn't work from cron

Open vnv099 opened this issue 5 years ago • 2 comments

I tried getssl script on 10.4-RELEASE-p13 FreeBSD. Just adding to crontab string like from readme - 23 5 * * * /root/scripts/getssl -u -a -q doesn't work, but from command line all working perfectly. It is something with PATH, that uses cron, because to solve this issue I had to make own script, set another PATH there and run it from crontab. Script is:

#!/usr/local/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/etc/rc.d
/usr/local/bin/getssl -w /etc/getssl -u -a

vnv099 avatar Jul 24 '20 08:07 vnv099

What error message did it give? I wouldn't be surprised if it couldn't find curl or openssl. Note that you can add a PATH=... line to your crontab, so that getssl doesn't need to be wrapped in another script.

wurtel2 avatar Sep 02 '20 18:09 wurtel2

I think the relevant difference that makes it work with your script isn't the PATH, but that you've explicitly specified the working directory using -w /etc/getssl.

I just ran into a very similar issue while moving my getssl instance from cron to a systemd timer.

  • When called from cron, getssl expected the domain-config subdirectories at /root/.getssl/example.com
  • but when called from the timer, even with the correct WorkingDirectory=/root/.getssl/ in the .service file, it apparently expected to find them at /.getssl/example.com. Without hand-feeding getssl -w /root/.getssl it would just return successfully after having done nothing at all. Asking it to check only one specific domain finally allowed me to pinpoint where it was looking.

dawidi avatar Jan 03 '21 14:01 dawidi