-1

I have an object on my database containing rows with different dates + emails. I need the server to automatically check once every day or week if any of the listed dates are the current date, and if so send an email to that person. (Image of the object in backand below).

backend object

I have made an email "on demand action" at the server side logic and operations in backand, which works, but i have to trigger it manually. Instead i need the server to trigger it on a specific time.

Is this possible to do, and if so how?

A solution i was thinking of, is having a function which is looping through the object, checking dates and sending the emails. And then somehow make the server run this function once per day/week or something.

qua1ity
  • 565
  • 2
  • 8
  • 27
  • 5
    Sounds like a perfect task for `cron` http://kvz.io/blog/2007/07/29/schedule-tasks-on-linux-using-crontab/ – Patrick Moore Aug 12 '16 at 16:22
  • which is your server unix based or windows based? – naveen Aug 12 '16 at 16:29
  • not sure, the site is hosted on one.com however. And using backand as BaaS – qua1ity Aug 12 '16 at 16:47
  • @qua1ity you'll probably need a VPS of some sort so you can actually configure things on the OS since cron or schedule task execution (and running any custom script) is going to require it unless the service your using offers this as an option in their settings/control panel. – shaunhusain Aug 12 '16 at 17:26
  • Alternatively the trigger could happen from outside the actual server but this leaves it open to being potentially triggered by anyone, if you have some secret it may work but depending on the magnitude of the possible problems that opens up would have to weigh if it's worth doing. – shaunhusain Aug 12 '16 at 17:27

2 Answers2

1

Cron solution is something we plan to add in the next few weeks, but in the meanwhile, we have a good FREE solution that let you do it.

The service is https://www.easycron.com.

You just need to specify the URL of the action, which you can get from the test action panel (after executing it in test mode).

To gain access to the action, you need to implement the basic authentication which means to use the masterKeyToken( Security & Auth--> Configuration) and an adminKey (Security & Auth--> Team--> click on the key icon near one of the Admins) like that:

https://masterKeyToken:adminKey@api.backand.com/1/objects/action/ObjectName1?name=YourActionName

To read more on Basic auth click here: http://docs.backand.com/en/latest/apidocs/security/#basic-authentication

Itay
  • 734
  • 4
  • 5
0

Cronjobs are the way to go.

If your hoster does not support cronjobs you have no chance to do it well. A quick google shows me that one.com MAY not support cronjobs. But I'm not sure.

Maybe ask the support.

If they does not I would choose a different hoster which is not shitty. (Only a shitty hoster does not support crons. I'm not saying one.com is such hoster because I don't know).

If you don't want to and they don't offer crons you could use "Poor Mens Cron". It's a crappy hack from ancient times of the Internet. You can google that because I wouldn't recommend.

Patrick
  • 1,562
  • 1
  • 16
  • 33
  • Just asked the support at One, and apparently their servers does not support cron jobs.. – qua1ity Aug 12 '16 at 17:39
  • My recommandation now is clearly: change your webhost. Cronjobs are kind of basic functionality and in general the prices seem to be too low for a good hosting. Protip: maybe consider a host which is not on the comparison table of one.com (on the index page). – Patrick Aug 12 '16 at 20:13
  • alright thank you, will look into it. Also stumbled upon sites like this one https://www.setcronjob.com do you think that could be an option? – qua1ity Aug 12 '16 at 20:47
  • With the Service the Script MUST be Public abailable. It's a Little Security concern. With real cronjobs on your Server the Script can be everywhere. – Patrick Aug 13 '16 at 07:01
  • But yes. It is possible. – Patrick Aug 13 '16 at 07:01