sesardelaisla
New Around Here
Hello Everyone,
My first message here, although I have learnt a lot by reading many posts and solutions here in the past! For the first time, I hope you can help with a topic I haven't found a way to fix it by searching previously in the forum.
I have a script file which it is executed fine if issued straight from the command line. The purpose of the script is to renew a few domain certificates I have. However, when the file is executed through a cron job, it seems some steps are skipped. Actually, the skipped steps are the most important ones (the dehydrated ones).
The cron service is running fine. The task is also executed, so no issues related to whether the main task is configured right. In the other hand, the router is set with JFFS services-start "cron a" line for such task, so cron jobs are reloaded upon every reboot and executed at the expected time.
As you can see below in the script, I have included some code after every line to be able to insert the commands output in the existing renew_certs.log file.
This is the script [renew_certs]:
This is the renew_certs.log output when the script renew_certs is issued from the command line:
And this is the renew_certs.log output when the script renew_certs is executed through the cron job:
If issued from the command line, all steps are executed and output is inserted in the log file as expectedd. However, if the script is executed from the cron job, the date command outputs are the only ones inserted in the log file. On top of that, it is not just an output logging problem, but a command execution problem as well. The bash lines between the date lines are not executed at all. Any way to fix this? What am I doing wrong?
For your reference, I have an ASUS RT-AX58U router with Merlin version 3004.388.6 installed (latest).
Thanks for taking time to read this post. I hope you can help. Cheers!
sesardelaisla
My first message here, although I have learnt a lot by reading many posts and solutions here in the past! For the first time, I hope you can help with a topic I haven't found a way to fix it by searching previously in the forum.
I have a script file which it is executed fine if issued straight from the command line. The purpose of the script is to renew a few domain certificates I have. However, when the file is executed through a cron job, it seems some steps are skipped. Actually, the skipped steps are the most important ones (the dehydrated ones).
The cron service is running fine. The task is also executed, so no issues related to whether the main task is configured right. In the other hand, the router is set with JFFS services-start "cron a" line for such task, so cron jobs are reloaded upon every reboot and executed at the expected time.
As you can see below in the script, I have included some code after every line to be able to insert the commands output in the existing renew_certs.log file.
This is the script [renew_certs]:
Code:
#!/bin/bash
date >> /jffs/scripts/renew_certs.log
bash /opt/etc/nginx/dehydrated --domain domain01.com --cron | tee -a /jffs/scripts/renew_certs.log
bash /opt/etc/nginx/dehydrated --domain domain02.com --cron | tee -a /jffs/scripts/renew_certs.log
bash /opt/etc/nginx/dehydrated --domain domain03.com --cron | tee -a /jffs/scripts/renew_certs.log
nginx -s reload
date >> /jffs/scripts/renew_certs.log
This is the renew_certs.log output when the script renew_certs is issued from the command line:
Code:
Fri Jan 26 15:07:14 CET 2024
# INFO: Using main config file /tmp/mnt/USB_ASUS/entware/etc/nginx/config
Processing domain01.com
+ Checking domain name(s) of existing cert... unchanged.
+ Checking expire date of existing cert...
+ Valid till Mar 27 20:42:47 2024 GMT (Longer than 30 days). Skipping renew!
# INFO: Using main config file /tmp/mnt/USB_ASUS/entware/etc/nginx/config
Processing domain02.com
+ Checking domain name(s) of existing cert... unchanged.
+ Checking expire date of existing cert...
+ Valid till Mar 27 20:43:00 2024 GMT (Longer than 30 days). Skipping renew!
# INFO: Using main config file /tmp/mnt/USB_ASUS/entware/etc/nginx/config
Processing domain03.com
+ Checking domain name(s) of existing cert... unchanged.
+ Checking expire date of existing cert...
+ Valid till Mar 27 20:43:17 2024 GMT (Longer than 30 days). Skipping renew!
Fri Jan 26 15:07:21 CET 2024
And this is the renew_certs.log output when the script renew_certs is executed through the cron job:
Code:
Fri Jan 26 15:18:00 MET 2024
Fri Jan 26 15:18:00 MET 2024
If issued from the command line, all steps are executed and output is inserted in the log file as expectedd. However, if the script is executed from the cron job, the date command outputs are the only ones inserted in the log file. On top of that, it is not just an output logging problem, but a command execution problem as well. The bash lines between the date lines are not executed at all. Any way to fix this? What am I doing wrong?
For your reference, I have an ASUS RT-AX58U router with Merlin version 3004.388.6 installed (latest).
Thanks for taking time to read this post. I hope you can help. Cheers!
sesardelaisla