TopologyUpdater log and cron job question

I have setup the topologyUpdater.sh and it seems to work well when run via the command line.
It gives me the friendly messages and updates the topologyUpdater_latestresults.json file.

So I set up a cron job: (here set for the 42nd minute of every hour)

42 * * * * /home/ada/pi-pool/scripts/topologyUpdater.sh

and it looks like it is running correctly:

Mar 28 14:41:01 ubuntu cron[278140]: (ada) RELOAD (crontabs/ada)
Mar 28 14:42:01 ubuntu CRON[278238]: pam_unix(cron:session): session opened for user ada by (uid=0)
Mar 28 14:42:01 ubuntu CRON[278239]: (ada) CMD (/home/ada/pi-pool/scripts/topologyUpdater.sh)
Mar 28 14:42:02 ubuntu CRON[278238]: pam_unix(cron:session): session closed for user ada

However, despite this CRON log, the topologylog file doesn’t show an updated notification.
I only seem to get one if I run it manually.

Does this mean it is not running? Or is it hiding the log somewhere else?

Thanks for the help!
-Sully

Hi!

Are you referring to $LOG_DIR/topologyUpdater_lastresult.json file? so when you execute manually this file is updated with new info, but not with cron?

Hi laplasz. Was hoping someone else might chime in to give you a break from my questions. :wink:

But yes, exactly.

:slight_smile: just logged in when you opened this topic…
so the only thing could be wrong is that the env file is not available at the time of calling the script…
so I would redirect all the outputs of the execution into a file first, and see what is going on:

42 * * * * /home/ada/pi-pool/scripts/topologyUpdater.sh 2>&1 /home/ada/pi-pool/scripts/topologyUpdater.log_cron

hmm. Get the same CRON status looking like it ran, but no log file was created.

ada@ubuntu:~/pi-pool/scripts$ sudo systemctl status cron
â—Ź cron.service - Regular background program processing daemon
Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2021-03-28 14:18:27 UTC; 2h 29min ago
Docs: man:cron(8)
Main PID: 278140 (cron)
Tasks: 1 (limit: 9314)
CGroup: /system.slice/cron.service
└─278140 /usr/sbin/cron -f

Mar 28 15:42:01 ubuntu CRON[278405]: pam_unix(cron:session): session opened for user ada by (uid=0)
Mar 28 15:42:01 ubuntu CRON[278406]: (ada) CMD (/home/ada/pi-pool/scripts/topologyUpdater.sh)
Mar 28 15:42:01 ubuntu CRON[278405]: pam_unix(cron:session): session closed for user ada
Mar 28 16:17:01 ubuntu CRON[278744]: pam_unix(cron:session): session opened for user root by (uid=0)
Mar 28 16:17:01 ubuntu CRON[278745]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Mar 28 16:17:01 ubuntu CRON[278744]: pam_unix(cron:session): session closed for user root
Mar 28 16:41:01 ubuntu cron[278140]: (ada) RELOAD (crontabs/ada)
Mar 28 16:42:01 ubuntu CRON[278790]: pam_unix(cron:session): session opened for user ada by (uid=0)
Mar 28 16:42:01 ubuntu CRON[278791]: (ada) CMD (/home/ada/pi-pool/scripts/topologyUpdater.sh 2>&1 /home/ada/pi-pool/scripts/topologyUpdater.log_cron)
Mar 28 16:42:02 ubuntu CRON[278790]: pam_unix(cron:session): session closed for user ada

-Sully

I made a typo: the correct redirect is
42 * * * * /home/ada/pi-pool/scripts/topologyUpdater.sh > /home/ada/pi-pool/scripts/topologyUpdater.log_cron 2>&1

may be your topology updater logs work with relative directory path.
cronjob is running on root path. cause you have to check relative path error.

Thanks guys, that is totally what is was. laplasz’s redirect showed that cron could not find the binaries for cardano-cli. So I found the right path and modified the env file for an absolute path to my /.local/bin and now it seems to be working fine. Couldn’t find what the error was until I did that redirect. Here’s another thread regarding the same issue.

Thanks again!
-Sully

1 Like