I need cron runs every 5 mins

Discussion forum about Anuko Time Tracker
Post Reply
dell810
Posts: 41
Joined: Sat Oct 01, 2016 1:09 pm

I need cron runs every 5 mins

Post by dell810 » Tue Mar 13, 2018 7:32 am

Hi,
Is it possible to send a favorite report every 5 min from 7:00am to 9:00am, every day (Monday - Friday)?
cron notification: 0,05 * * * 1-5

I need cron runs every 5 mins
Thanks

wrc
Posts: 244
Joined: Tue May 25, 2010 8:30 pm

Re: I need cron runs every 5 mins

Post by wrc » Tue Mar 13, 2018 3:28 pm

dell810 wrote:Hi,
Is it possible to send a favorite report every 5 min from 7:00am to 9:00am, every day (Monday - Friday)?
cron notification: 0,05 * * * 1-5

I need cron runs every 5 mins
Thanks
There are 2 things to do.

1) Modify cron spec as so:

Code: Select all

0,5,10,15,20,25,30,35,40,45,50,55 7-8 * * 1-5
2) Makes sure that cron.php file in Time Tracker is called at least that often. Perhaps you want it to run every minute for testing. Once things are working, reduce frequency (and load) on your server to something more appropriate.

dell810
Posts: 41
Joined: Sat Oct 01, 2016 1:09 pm

Re: I need cron runs every 5 mins

Post by dell810 » Tue Mar 13, 2018 4:05 pm

Thanks for the answer
1. ok
2. Sorry, how can I do this?

wrc
Posts: 244
Joined: Tue May 25, 2010 8:30 pm

Re: I need cron runs every 5 mins

Post by wrc » Tue Mar 13, 2018 4:43 pm

See if this helps: https://www.anuko.com/time_tracker/user ... ations.htm

Basically, on the server that runs your Time Tracker, you need to configure a regular execution of cron.php file in the root directory of Time Tracker install.

If you use a Unix / Lunix like system, you can configure a cron program to do this. From that page above:
Processing occurs when cron.php script is executed. It compares tt_cron.next value with now and, if a report is due, sends it out and re-calculates its next run time. Therefore, timing accuracy actually depends on how often cron.php is called. To match cron spec precisely, you'll need to call it every minute but this will add unnecessary load on your server. Configure your timing wisely. We recommend hourly or even less frequent pings.

Below is an example of crontab entry to process notifications hourly at 5 minutes past each hour.

# timetracker ping to execute scheduled jobs
MAILTO=""
5 * * * * root /usr/bin/php /var/www/timetracker/cron.php
If you use a Windows box, you can try Task Scheduler.

If you don't have access to the server to accomplish the above, you can try accessing the cron.php page remotely, via an HTTP request, on regular intervals.

I hope it helps.

dell810
Posts: 41
Joined: Sat Oct 01, 2016 1:09 pm

Re: I need cron runs every 5 mins

Post by dell810 » Wed Mar 14, 2018 12:59 pm

Hi again,
I use a pc with windows 8 and xampp.
I added 2 notification (at notifications plugin):
0,5,10,15,20,25,30,35,40,45,50,55 7-9 * * 1-5 => every 5 min from 7:00am to 9:00am, every day (Monday - Friday)
0,5,10,15,20,25,30,35,40,45,50,55 14-16 * * 1-5 => every 5 min from 2:00mm to 4:00mm, every day (Monday - Friday)

I added 2 tasks at task scheduler:
7-9-5min.jpg
2-4-5min.jpg

but I do not receive any favorite reports
Pls can you check it?
Attachments
2-4-5min.JPG
2-4-5min.JPG (42.43 KiB) Viewed 336 times
7-9-5min.JPG
7-9-5min.JPG (43.38 KiB) Viewed 336 times

wrc
Posts: 244
Joined: Tue May 25, 2010 8:30 pm

Re: I need cron runs every 5 mins

Post by wrc » Wed Mar 14, 2018 2:06 pm

dell810 wrote:Hi again,
I use a pc with windows 8 and xampp.
Why Windows? I suggest trying a better, more secure, and free OS, such as Ubuntu or something else Linux based with a nice desktop UI, simply because of ongoing evil we are getting from Redmond for a long time now.

But if you insist on Windows, try to resolve the problem in steps.

1) Is your mail working? Try to send yourself a password reminder to confirm.

2) Is your notification in Time Tracker configured in a way that it sends out at least some reports? Try to use a browser and access your /cron.php page in browser, for example: http://localhost/timetracker/cron.php - this should output something. The following means no reports were sent:

Code: Select all

Done!
Additional strings before Done! indicate that some reports were sent and you should see them in the mailbox. Try this again after 5 minutes to see if the next report is sent as expected, and your cron configuration is correct. Assuming that all of the above works, proceed with step 3).

3) What exactly is your task action doing? You have not provided that screenshot and I suspect that this could be your problem. What happens if your execute that task manually in Task Scheduler? Nothing? The task action should access the cron.php URL to get the job done.

3.1) We need to create a script that does the polling (without Task Scheduler). Based on answer at https://stackoverflow.com/questions/470 ... edule-task
Locate the php.exe executable on your system and pass it the name of the script file using the -f parameter.

Example:

C:\Xampp\php\php.exe -f C:\Xampp\htdocs\timetracker\cron.php
Execute the command manually. Does it mail he report? If so, then the last step is to use this script as an action for your Task Scheduler job.

3.2) Configure task action in Task Scheduler to run the script. See if this helps https://www.digitalcitizen.life/advance ... -scheduler - the bottom section on this page has some pictures related to this.

I hope it helps.

Post Reply