06Games / Webtrees-MailSystem

Webtrees module for sending newsletters at regular intervals
GNU General Public License v3.0
6 stars 5 forks source link

error in cronjob #10

Closed Joppla closed 1 year ago

Joppla commented 1 year ago

Hi,

I just see your message. Yesterday I installed the mailsystem module. Today I should get the first mail, but I got this error message:

/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file

The cronjob is:

0 7 * * * /usr/local/bin/wget -O - -q "https://mydomain.info/index.php?route=%2Fmail-sys%2Fcron" > /dev/null

Is this error connected with your message before, or is this something else?

06Games commented 1 year ago

Hi, Thank you for opening this issue. It doesn't seem to me that the error is coming from the execution of the wget, but to be sure, can you execute the command manually ?

/usr/local/bin/wget -O - -q "https://mydomain.info/index.php?route=%2Fmail-sys%2Fcron" > /dev/null
Joppla commented 1 year ago

I presume that I should do it on the ssh connection? If yes, nothing happened, no error, but also no mail.

06Games commented 1 year ago

Yes, this is to be run in the terminal, could you try this

wget -O - -q "https://mydomain.info/index.php?route=%2Fmail-sys%2Fcron"
Joppla commented 1 year ago

Hi, that didn't give any result.

I also tested if the installation can send mail, but that is possible.

06Games commented 1 year ago

This is strange. If you connect to this URL (https://mydomain.info/index.php?route=%2Fmail-sys%2Fcron) from a browser, it doesn't work either? Maybe also try this one, it should respond with a JSON containing information about the module: https://mydomain.info/index.php?route=%2Fmail-sys%2Fhelp

Joppla commented 1 year ago

That give a lot ;-), but not a mail )-:

Call to a member function format() on null …/modules_v4/Webtrees-MailSystem/Helpers/News.php:20
#0 …/modules_v4/Webtrees-MailSystem/RequestHandler.php(187): EvanG\Modules\MailSystem\Helpers\News->get()
#1 [internal function]: EvanG\Modules\MailSystem\RequestHandler->EvanG\Modules\MailSystem\{closure}()
#2 …/vendor/illuminate/collections/Collection.php(695): array_map()
#3 …/modules_v4/Webtrees-MailSystem/RequestHandler.php(192): Illuminate\Support\Collection->map()
#4 …/modules_v4/Webtrees-MailSystem/RequestHandler.php(153): EvanG\Modules\MailSystem\RequestHandler->api()
#5 …/modules_v4/Webtrees-MailSystem/RequestHandler.php(134): EvanG\Modules\MailSystem\RequestHandler->htmlData()
#6 …/modules_v4/Webtrees-MailSystem/RequestHandler.php(124): EvanG\Modules\MailSystem\RequestHandler->sendMail()
#7 …/modules_v4/Webtrees-MailSystem/RequestHandler.php(113): EvanG\Modules\MailSystem\RequestHandler->sendMails()
#8 …/modules_v4/Webtrees-MailSystem/RequestHandler.php(63): EvanG\Modules\MailSystem\RequestHandler->cron()
#9 …/modules_v4/Webtrees-MailSystem/RequestHandler.php(206): EvanG\Modules\MailSystem\RequestHandler->EvanG\Modules\MailSystem\{closure}()
#10 …/app/Http/Middleware/RequestHandler.php(55): EvanG\Modules\MailSystem\RequestHandler->handle()
#11 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\RequestHandler->process()
#12 …/app/Module/CheckForNewVersion.php(115): Middleland\Dispatcher->handle()
#13 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Module\CheckForNewVersion->process()
#14 …/app/Http/Middleware/CheckCsrf.php(80): Middleland\Dispatcher->handle()
#15 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\CheckCsrf->process()
#16 …/vendor/oscarotero/middleland/src/Dispatcher.php(118): Middleland\Dispatcher->handle()
#17 …/app/Webtrees.php(275): Middleland\Dispatcher->dispatch()
#18 …/app/Http/Middleware/Router.php(152): Fisharebest\Webtrees\Webtrees::dispatch()
#19 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\Router->process()
#20 …/app/Http/Middleware/BootModules.php(60): Middleland\Dispatcher->handle()
#21 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\BootModules->process()
#22 …/app/Http/Middleware/RegisterGedcomTags.php(54): Middleland\Dispatcher->handle()
#23 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\RegisterGedcomTags->process()
#24 …/app/Http/Middleware/LoadRoutes.php(75): Middleland\Dispatcher->handle()
#25 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\LoadRoutes->process()
#26 …/app/Http/Middleware/CheckForNewVersion.php(57): Middleland\Dispatcher->handle()
#27 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\CheckForNewVersion->process()
#28 …/app/Http/Middleware/UseTransaction.php(45): Middleland\Dispatcher->handle()
#29 …/vendor/illuminate/database/Concerns/ManagesTransactions.php(29): Fisharebest\Webtrees\Http\Middleware\UseTransaction::Fisharebest\Webtrees\Http\Middleware\{closure}()
#30 …/app/Http/Middleware/UseTransaction.php(46): Illuminate\Database\Connection->transaction()
#31 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseTransaction->process()
#32 …/app/Http/Middleware/DoHousekeeping.php(73): Middleland\Dispatcher->handle()
#33 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\DoHousekeeping->process()
#34 …/app/Http/Middleware/UseTheme.php(69): Middleland\Dispatcher->handle()
#35 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseTheme->process()
#36 …/app/Http/Middleware/CheckForMaintenanceMode.php(51): Middleland\Dispatcher->handle()
#37 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\CheckForMaintenanceMode->process()
#38 …/app/Http/Middleware/UseLanguage.php(71): Middleland\Dispatcher->handle()
#39 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseLanguage->process()
#40 …/app/Http/Middleware/UseSession.php(78): Middleland\Dispatcher->handle()
#41 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseSession->process()
#42 …/app/Http/Middleware/UpdateDatabaseSchema.php(57): Middleland\Dispatcher->handle()
#43 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UpdateDatabaseSchema->process()
#44 …/app/Http/Middleware/UseDatabase.php(118): Middleland\Dispatcher->handle()
#45 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\UseDatabase->process()
#46 …/app/Http/Middleware/BadBotBlocker.php(277): Middleland\Dispatcher->handle()
#47 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\BadBotBlocker->process()
#48 …/app/Http/Middleware/CompressResponse.php(73): Middleland\Dispatcher->handle()
#49 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\CompressResponse->process()
#50 …/app/Http/Middleware/ContentLength.php(40): Middleland\Dispatcher->handle()
#51 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\ContentLength->process()
#52 …/vendor/middlewares/client-ip/src/ClientIp.php(65): Middleland\Dispatcher->handle()
#53 …/app/Http/Middleware/ClientIp.php(47): Middlewares\ClientIp->process()
#54 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\ClientIp->process()
#55 …/app/Http/Middleware/HandleExceptions.php(90): Middleland\Dispatcher->handle()
#56 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\HandleExceptions->process()
#57 …/app/Http/Middleware/BaseUrl.php(73): Middleland\Dispatcher->handle()
#58 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\BaseUrl->process()
#59 …/app/Http/Middleware/ReadConfigIni.php(68): Middleland\Dispatcher->handle()
#60 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\ReadConfigIni->process()
#61 …/app/Http/Middleware/SecurityHeaders.php(48): Middleland\Dispatcher->handle()
#62 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\SecurityHeaders->process()
#63 …/app/Http/Middleware/EmitResponse.php(57): Middleland\Dispatcher->handle()
#64 …/vendor/oscarotero/middleland/src/Dispatcher.php(136): Fisharebest\Webtrees\Http\Middleware\EmitResponse->process()
#65 …/vendor/oscarotero/middleland/src/Dispatcher.php(118): Middleland\Dispatcher->handle()
#66 …/app/Webtrees.php(275): Middleland\Dispatcher->dispatch()
#67 …/app/Webtrees.php(262): Fisharebest\Webtrees\Webtrees::dispatch()
#68 …/index.php(51): Fisharebest\Webtrees\Webtrees->httpRequest()
#69 {main}
06Games commented 1 year ago

The good news is that it gives an error, so we can locate the problem ;) This is a really stupid mistake I made in the code, I will be able to fix it quickly

Joppla commented 1 year ago

Most times it are stupid mistakes ;-) I am happy that you found it, success with repair and thanks for helping!

06Games commented 1 year ago

Yes, totally. Could you test with the latest commit: https://github.com/06Games/Webtrees-MailSystem/archive/5816dbc386146e372d3a56db9e27efe456b9cb11.zip

Joppla commented 1 year ago

It works! Thanks!

Joppla commented 1 year ago

I am sorry that I have to re-open this issue. The cronjob in the browser works correct. But the cronjob itself gave this morning still the same error by mail. See the first message in this.

06Games commented 1 year ago

Hi, What does the execution of this command return?

wget -O - -q "https://mydomain.info/index.php?route=%2Fmail-sys%2Fcron"
Joppla commented 1 year ago

I tested and got the following message:

{"message":"Skip","today":"2022-12-10","next":"2022-12-11"}

But I didn't got a mail.

06Games commented 1 year ago

Everything is fine, as the message says, the mailing is scheduled for tomorrow. The error you are getting must come from your cron configuration. Check that the other tasks in your cron file are working properly.

Joppla commented 1 year ago

Other task work correct.

I modified to run the cron within 2 minutes. But still get an error mail instead of suspected.

/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file
06Games commented 1 year ago

You receive this in an email?

Joppla commented 1 year ago

yes, by mail

06Games commented 1 year ago

It's really weird, the module doesn't use sh at all. The sender of the email is Webtrees?

Joppla commented 1 year ago

no, the sender seems me the cron deamon, the webserver: debxxxxx@s223.webhostingserver.nl

subj: Cron debxxxxx@s223 wget -O - -q "https://mydomain.info/index.php?route=

Seems me strange that not the whole cron is in the subject, but it is shortened after "route="

06Games commented 1 year ago

Yes, for me too, maybe we need to escape the %. I must admit that I only tested this module with the pretty url, so it is possible that it comes from there

Joppla commented 1 year ago

Why doesn't I got an email when I run wget -O - -q "https://mydomain.info/index.php?route=%2Fmail-sys%2Fcron" in the terminal, but I got the mail when I run https://mydomain.info/index.php?route=%2Fmail-sys%2Fcron in the browser?

06Games commented 1 year ago

Yes, for me too, maybe we need to escape the %. I must admit that I only tested this module with the pretty url, so it is possible that it comes from there

Indeed, it would seem that a \ should be added before the %. https://stackoverflow.com/a/53095846/10792036 Could you try this cron task:

0 7 * * * /usr/local/bin/wget -O - -q "https://mydomain.info/index.php?route=\%2Fmail-sys\%2Fcron" > /dev/null
06Games commented 1 year ago

Why doesn't I got an email when I run wget -O - -q "https://mydomain.info/index.php?route=%2Fmail-sys%2Fcron" in the terminal, but I got the mail when I run https://mydomain.info/index.php?route=%2Fmail-sys%2Fcron in the browser?

There should be no difference. What are the sending dates that are displayed at the bottom of the module configuration page?

Joppla commented 1 year ago
Information

Last mailing: 2022-12-10
Next mailing: 2022-12-11
Number of recipients: 1
Joppla commented 1 year ago

with "\%2F" nor "\/" I got an error mail now. Also not another mail, but that has to be with the setting that only once day a mail will be send?

06Games commented 1 year ago
Information

Last mailing: 2022-12-10
Next mailing: 2022-12-11
Number of recipients: 1

And if you re-request https://mydomain.info/index.php?route=%2Fmail-sys%2Fcron in your browser it sends an email again? Normally, you should not be able to get more than one email per day.

06Games commented 1 year ago

with "%2F" nor "/" I got an error mail now. Also not another mail, but that has to be with the setting that only once day a mail will be send?

You should apparently write \%2F and not just %2F because % is a special character

Joppla commented 1 year ago

I ve tested now without > /dev/null. Now I got a mail with my complete start -page of the website. I presume that the correction with \/ or \%2F is right. We will see tomorrow morning.

You should apparently write \%2F and not just %2F because % is a special character

That is a misunderstanding, github did not understand \ correct. ;-)

06Games commented 1 year ago

The route is not understood if it sends you the home page. So the problem has not been solved... Could you send me the exact cron command you are using, I will try to reproduce the problem.

Joppla commented 1 year ago

17 * * * * /usr/local/bin/wget -O - -q "https://mydomain.info/index.php?route=\/mail-sys\/Fcron"

With or without > /dev/null

And if you re-request https://mydomain.info/index.php?route=%2Fmail-sys%2Fcron in your browser it sends an email again?

Now I don't get a mail anymore.

06Games commented 1 year ago

In my tests, this cron task worked:

0 8 * * * wget -O - -q "https://localhost/index.php?route=\%2Fmail-sys\%2Fcron"
Joppla commented 1 year ago

In my tests, this cron task worked:

0 8 * * * wget -O - -q "https://localhost/index.php?route=\%2Fmail-sys\%2Fcron"

I agree.