CLI TOOLS

Hello members,

I’ve been testing the cron job CLI and apparently the last in the example https://docs.gibbonedu.org/administrators/misc/command-line-tools/

“0 1 * * * cd /var/www/gibbon/cli/ ; php userAdmin_statusCheckAndFix.php” is the command that is working and outputs:
-bash: 33: command not found
Sent 1 notifications: 1 inserts, 0 updates, 1 emails sent, 0 emails failed.

but when I try : “0 1 * * * cd /var/www/gibbon/cli/ ; php attendance_weeklySummaryEmail.php” the output is:
-bash: 33: command not found

and no email for the above CLI command plus the rest in the /var/www/gibbon/cli/ folder are notifying me for mails sent. I’ve tried changing the cron job time and even using “sudo” to probably bypass permission but still no mails sent.

Is there something I am doing wrong…?

distro:
Distributor ID: Debian
Description: Debian GNU/Linux 9.13 (stretch)
Release: 9.13
Codename: stretch

Hi Kelvin,

The PHP that runs in the web server (e.g. Apache, nginx) is seperate from the one that run via bash. I wonder if perhaps the “command not found” is php. Can you SSH into your server and run php -v from the command line to see what you get?

I would assume that it is installed by default…but perhaps not.

Thanks,

Ross

Hi Ross,
Thank you for response.
This is the version:

PHP 7.4.14 (cli) (built: Jan 12 2021 14:00:40) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.14, Copyright (c), by Zend Technologies

Hmmm, interesting. Seems like PHP is available from the command line. Can you try to run the two commands that are called from the cron script, in command line, one at a time:

  1. cd /var/www/gibbon/cli/
  2. php userAdmin_statusCheckAndFix.php

Do either of those throw up the same “command not found” error?

Ross

I tried:
php userAdmin_statusCheckAndFix.php`
and the output:
Sent 1 notifications: 1 inserts, 0 updates, 1 emails sent, 0 emails failed.

which shows success.
while
php attendance_weeklySummaryEmail.php`
outputs nothing / no feed

Thank You.

It is odd that you are getting “command not found” whether or not the action succeeds. Not all the CLI scripts output to screen, so the fact that the second one does not print anything (other than the error) is not on its own evidence that nothing is going wrong.

Do you have attendance data in the week in question? Are emails from elsewhere in the system, such as notifications or Messenger, sending?

Ross

Yes I have data for that week and visible in the system. emails are sending perfectly (I am using sendgrid API connection to VM).
After executing the commands I don’t get notified even after logging into the system.

I took a break, today I’ll try doing some little settings, changes and clearing cache then see if there’s any changes.

Thank You.

Hi Kelvin,

I noticed your thread and took a peek at the script to refresh my memory. Weekly Attendance Summary is a CLI script that uses notifications to send emails. Perhaps check in System Admin > Notification Settings to see if you’re subscribed to receive notifications for the Weekly Attendance Summary event.

Hi Sandra & Ross,

Yes I had made the necessary notification subscriptions.
I found out a solution to those who will experience this similar Issue, I think it’s some distros where you have to specify the php binary path as follows:

  1. SSH to you VM and locate you PHP path in the terminal by typing:
    whereis php`
    output: /usr/bin/php7.4
  2. then open cron job editor:
    sudo cronetab -e `
  3. edit your cron job including the PHP path as :
    0 8 * * 4 cd /usr/bin/php7.4 /var/www/gibbon/cli/attendance_weeklySummaryEmail.php
    `
  4. Write out: CTRL+O

Then your done! :smile:

Fantastic, that is great to know and have on record here. Thanks for taking the time to share : )