automatic daily server email

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

automatic daily server email

Post by D Oliveira » 2020-06-26 10:42

Hey folks, in one of my projects the user has to log data in their diary every day, I made a php script that scans the database and if no entry was found an email is sent reminding the user to log in the diary. Question is, how how can I make that automatic, never handled CRON jobs before so can anyone share a strategy on how to approach this?

Thank you

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: automatic daily server email

Post by onoehring » 2020-06-26 12:18

Hi Oliveira,

there are several possibilities.
a) you have access to a real cron on your system. You should be able to find some information about this on the web . Maybe https://crontab-generator.org or https://crontab.guru or https://foswiki.org/Support/CronWizard will do.
b) your webprovider might offer a cron job. I have seen this several times with a very easy to use web wizard.
c) create a cronjob using some service on the web https://www.easycron.com/ or https://www.cronjob.de
d) create your own script and run that every X minutes/seconds.

Whatever way you can use /decide to use, cron will do nothing but simply call the URL you supply.
This should make it obvious, that you might want to secure your script with some security check (like a password in the URL which is needed if the script is being run: https://example.com/automatic/mycron.php?pw=MySecret ).
Also you might want to have your script create some output, so that you can see that it has been run.

Enough information? If not, just ask again.

Olaf

User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

Re: automatic daily server email

Post by D Oliveira » 2020-06-26 15:24

Thank you for such a detailed explanation =) easycron.com was my choice, really simplified everything! Share your paypal email so I can show you some modest appreciation, I contacted appgini support and asked them to enable a section for paid services or donations and they said they might work on it so thats good news for the community, once again, thanks a lot.

Cheers


hernan
Posts: 26
Joined: 2020-06-22 18:56

Re: automatic daily server email

Post by hernan » 2020-06-30 19:53

Hi,

I personnally used Apps Script from Google https://script.google.com/, where you can create a short script calling the URL you want.
You can then set Triggers so it is executed when you want (daily, weekly, monthly, etc).

Code: Select all

function executeDailyEmailAlerts_inExternalApp() {
  var response = UrlFetchApp.fetch('https://yourAppUrl/yourscript.php');
  return "ok";
};
In each App Script file you can create as many functions as you want, and then set triggers for each function following different scenarios for each. For example you could want to execute a job everyday, but maybe once a week you need other information or calling other php script.... So you will have to create two functions in the same AppsScript file and set a trigger for each function. It's all in Javascript.

As stated by Olaf it is recommended to add some kind of security like a token in the URL that you will have to check before executing your php script.

User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

Re: automatic daily server email

Post by D Oliveira » 2020-07-03 09:59

thank you for taking the time, thats is also a clever way to approach this, already paid for the easycron subscription lol but will definitely give it a shot on my upcoming projects, thanks again mate.

Cheers

fciprian
Veteran Member
Posts: 52
Joined: 2020-04-20 10:51

Re: automatic daily server email

Post by fciprian » 2021-12-02 23:09

Hello!
Can you help me with the script that scans the database and if no entry was found email is sent?
It is useful for me also.

Thank you

Post Reply