Hey there, Awesome Customers!

Just a heads up: We'll be taking a breather to celebrate International Workers' Day (May 1st and 2nd - Wednesday and Thursday) and Orthodox Easter from Good Friday (May 3rd) through Easter Monday (May 6th). So, from May 1st to May 6th, our team will be off enjoying some well-deserved downtime.

During this time, our customer support will be running on a smaller crew, but don't worry! We'll still be around to help with any urgent matters, though it might take us a bit longer than usual to get back to you.

We'll be back in action at full throttle on May 7th (Tuesday), ready to tackle your questions and requests with gusto!

In the meantime, you can explore our documentation for Amelia and wpDataTables. You'll find loads of helpful resources, including articles and handy video tutorials on YouTube (Amelia's YouTube Channel and wpDataTables' YouTube Channel). These gems might just have the answers you're looking for while we're kicking back.

Thanks a bunch for your understanding and support!

Catch you on the flip side!

Warm regards,

TMS

Okay
  Public Ticket #2512624
Next day reminder cron job
Closed

Comments

  • Stine started the conversation

    Hi,

    I want to send email reminders (a day in advance) to people who've joined my upcoming events. I'm told to add this line to the cron:
    */15 * * * * https://wearesalonsalon.com/wp-admin/admin-ajax.php?action=wpamelia_api&call=/notifications/scheduled/send

    .. but I have no idea how to add this line.

    I can see 'Cron jobs' in cpanel, but I still don't get it.

    Please advise. Tx

  • [deleted] replied

    Hello Stine Bjerregaard,

    Cron setup depends on your server configuration, there are many ways to set it up so you can ask your hosting how to setup a cron on your website or you can check out a tutorial on how to set up cron at this link.

    If you are not familiar with this, our suggestion is for your to  use the plugin WP Crontrol for creating a cronjob.

    This is the instruction on how to create the cron for Amelia using it:

    In the Tools -> Cron Events admin panel, click on the “Add PHP Cron Event” tab underneath the cron event table.

    1..png1.-1024x447.png

    In the form that appears, enter the schedule and next run time in the boxes. The event schedule is how often your event will be executed. In the “PHP code” area, enter the PHP code that should be run when your cron event is executed. Please insert this:

    file_get_contents("https://yourwebsite.com/wp-admin/admin-ajax.php?action=wpamelia_api&call=/notifications/scheduled/send");

    You don’t need to provide the PHP opening tag (<?php).

    2..png2.-1024x454.png

    Please replace “https://yourwebsite.com” with your real web address.

    If you don’t see a good interval, then add one in the Settings -> Cron Schedules admin panel or click on the link “Manage Cron Schedules”. You will find an example of how you can make custom interval inserting:

    • Interval name
    • Interval(in seconds)
    • Display name
    3..png3.-1024x346.png

    and click “Add Cron Schedules” and it will be added.

    4..png4.-1024x123.png

    When you made custom interval you need to go back to  Tools -> Cron Events admin panel and click on the “Add PHP Cron Event” tab underneath the cron event table where you will insert that custom interval and all other fields that are described above. After clicking on “Add PHP Cron Event” it will be added on Event table and you are done.

    5..png

  • Stine replied

    Hi,

    The cron job is integrated in cPanel, so I just set it up there (with help from my hosting support). It seemed fairly simple, but for some reason emails yesterday were sent out around 19:45 (CET) although it was set to 17:00 .. Today there's been no emails sent out so far, although it was set to sent out at 11:30 (3,5 hours ago).

    Any idea how this can be? I've attached a screenshot of the cron job I've added.

  • [deleted] replied

    Hello Stine,

    Could you please check have you set your timezone in your WordPress General Settings , as this setting applies to Amelia as well. But this shouldn' t happen if they weren't sent at all , could you please check with your hosting is the cron working well on the website, is it called each 15 minutes, they can check the cron log? Also, when you change anything or book appointments please make sure that this time passes before the notification i s sent as the cron is called at specified times ( if you set it to 15 then on each 15 minutes).

    Also, do the other email notifications ( that don't require a cron) work well in Amelia ? Are they all sent and received?

  • Stine replied

    WP General Settings are correct.

    I've asked my hosting company support, and they said:

    "As our technicians have checked, the cron job run - 10 minutes ago last time."

    "I advise you to contact Amelia with this issue, because it seems that the issue is connected with the structure of cron job."

    .. so it looks like it's running, but not doing the job :/<

    All other Amelia nofications work. So it must be this cron job (setup maybe) that's not working.

    Did you see the cpanel cron job screenshot I attached? Does it look ok to you?

  • [deleted] replied

    It looks OK, I am not sure about that curl at the beginning, but this cron setup depends on server configuration so it is probably coming from there, we don't know the cron setup for all servers unfortunately. 

    You can try out the WP crontrol plugin using the instructions we explained in our FAQ section https://wpamelia.com/faq/ , and if that doesn't work either it is definitely some issue with the cron. 

    Also, you can try changing the cron to this, before trying out the plugin, some users found it helpful:

    */15 * * * * wget -q -O - "https://www.yourwebsite.com//wp-admin/admin-ajax.php?action=wpamelia_api&call=/notifications/scheduled/send"



  • Stine replied

    Ok, so I replace the 'curl https...' with 'wget -q -O - "https://www.yourwebsite.com//wp-admin/admin-ajax.php?action=wpamelia_api&call=/notifications/scheduled/send' ?

    I'll try this, once you've verified, and if it doesn't work either, I'll try the plugin.

  • [deleted] replied

    This 

    */15 * * * * https://www.yourwebsite.com/wp-admin/admin-ajax.php?action=wpamelia_api&call=/notifications/scheduled/send

    Is replaced with this

    */15 * * * * wget -q -O - "https://www.yourwebsite.com//wp-admin/admin-ajax.php?action=wpamelia_api&call=/notifications/scheduled/send"

    Again I am not sure about that curl maybe it is needed for your server, but you can try this out. 

  • Stine replied

    The code doesn't go into cpanel like you write, which is why I asked it so clearly.. However, it seems like a coinflip if it works, and it's already been a disaster for us that this doesn't work. So - I'll try your suggest plugin solution instead of the cpanel solution.

    Please check this video to see if I made it correctly:
    https://i.gyazo.com/a8f2ca8527fd74cb11d8a01116c12223.mp4

    This 15minutes seems to be correct, but I just want to state that the notifications must go out only to people signed up for an event a day in advance at 10:00 CET (UTC+2).

    I hope this looks ok and that the cron job notifications will work now. It's been so strange, with many not receiving notifications and others getting them to show the event time with two hours too early.

  • [deleted] replied

    Then it must be that the cron configuration on your server doesn't support that format. 

    Just change the Next run option to Now or choose the current time for the cron you made , so it works from now and so on on each 15 minutes. You shouldn't choose there the time that you set on the Amelia -> Notifications page for the Reminder notifications time.

    Please let me know of the outcome.

  • Stine replied

    Ok, Next Run changed to Now. I was just scared that it would send out email notifications now, but I guess the cron job will just start now, and sent out a day before like I've specified in the Amelia notifications.

  • [deleted] replied

    Yes, that option is for setting up when the cron job will start working, and the cron will recur now on 15 minutes, so at the time you specified for the Reminder notifications it will call out the notifications to be sent (for appointments that are booked for the next day). 

    cron is a Linux utility which schedules a command or script on your server to run automatically at a specified time and date. A cron job is the scheduled task itself. Cron jobs can be very useful to automate repetitive tasks like this one in our plugin for the notifications.