Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduled tasks not executing #7315

Closed
sirtet opened this issue Feb 27, 2015 · 13 comments
Closed

Scheduled tasks not executing #7315

sirtet opened this issue Feb 27, 2015 · 13 comments
Labels
answered For when a question was asked and we referred to forum or answered it.

Comments

@sirtet
Copy link

sirtet commented Feb 27, 2015

piwik-tasks

I thought my piwik install would run scheduled tasks automatically, triggered by the calls to the tracking, or something like that.
But now i see via the TasksTimetable Plugin, that all tasks are far behind, eg. next scheduled time = 3 days ago...
So, ist this normal, do i need to set up a cron or so to run them? If so, how?
Or is there a problem with my install?

@mnapoli
Copy link
Contributor

mnapoli commented Mar 1, 2015

triggered by the calls to the tracking

I don't think the tracking triggers the archiving/scheduled tasks, because that could result in a super slow response time. Please correct me if I'm wrong.

However visiting Piwik itself should trigger the browser archiving, are you sure it's not disabled? Have you tried accessing a report and then refresh the timetable to see if the archiving/scheduled tasks were executed?

Using cron is not necessary.

@mattab
Copy link
Member

mattab commented Mar 1, 2015

I don't think the tracking triggers the archiving/scheduled tasks, because that could result in a super slow response time. Please correct me if I'm wrong.

FYI: the calls to piwik.php will sometimes trigger the full archiving and the scheduled tasks. This is done to ensure a good user experience. Imagine that a user has selected "Allow browser to trigger archiving" to 'yes' in the settings, and that the user has not setup the core:archive cron. In this case, if we didn't trigger archiving+scheduled tasks in the tracker, and if the user does not connect to Piwik UI or API, then the email reports, custom alerts, and in general all of the data would not be processed until the next time the user visits Piwik. This would be bad user experience and it would seem Piwik is not working (email reports would not be received, and when user finally connects to the UI it would take ages to process data, making Piwik uber-slow).

Interestingly, when we broke this feature a few times over the years, each time many users noticed and reported the issue. I'm not sure where this logic is done in the code since we refactored Tracker recently but it should still be there.

@mnapoli
Copy link
Contributor

mnapoli commented Mar 1, 2015

@mattab thanks good to know!

@sirtet
Copy link
Author

sirtet commented Mar 1, 2015

So, there IS a bug, or something on my install?

@mnapoli
Copy link
Contributor

mnapoli commented Mar 1, 2015

should trigger the browser archiving, are you sure it's not disabled?

Have you disabled browser archiving?

@sirtet
Copy link
Author

sirtet commented Mar 2, 2015

No, i have it enabled: admin>settings>general>Archiving settings>>>YES

@mnapoli
Copy link
Contributor

mnapoli commented Mar 2, 2015

OK, do you have SSH access to the machine? If yes, could you try to run the archiving/scheduled tasks manually so that maybe any error/warning that prevents the tasks from running will show here:

./console core:run-scheduled-tasks

You could also enable logging to file, maybe the log will contain useful information. Add this to you config.ini.php:

[log]
log_writers[] = "file"
log_level = "INFO"

@sirtet
Copy link
Author

sirtet commented Mar 9, 2015

Tried so, can't run console:

$ ./console core:run-scheduled-tasks
-bash: ./console: Permission denied

Listing the files i see console is in a different group compared to eg. index.php...

-rw-r--r-- 1 myuser users 689 Mar 9 20:55 console
-rw-rw-r-- 1 myuser myuser 730 Mar 9 20:55 index.php
Do i need to change that?

Also, added to config.ini.php:

[log]
log_writers[] = "file"
logger_file_path = "./piwik.log"
log_level = "INFO"
Like that, i expected to get the log file in the piwik root, but can't see it after a few days. When is it normally written?

@mnapoli
Copy link
Contributor

mnapoli commented Mar 9, 2015

You need to fix the file permissions to run the console.

For the logger you customized the path so I don't know where it will be logged. Remove the logger_file_path line and it will be in tmp/logs/piwik.log.

@sirtet
Copy link
Author

sirtet commented Mar 10, 2015

Thanks, removed the logger path.

About permissions, i suspect there are others set incorrectly.
is there a way to check all permissions for validity?
What permissions are needed?

Just adding execute to the console script, i was able to run it, but no errors were shown:

$ ./console core:run-scheduled-tasks
Piwik\Plugins\CoreAdminHome\Tasks.purgeOutdatedArchives - Time elapsed: 1.932s
Piwik\Plugins\ExamplePlugin\Tasks.myTask - Time elapsed: 0.000s
Piwik\Plugins\ExcludeByDDNS\Tasks.updateIPs - Time elapsed: 0.041s
Piwik\Plugins\CoreAdminHome\Tasks.purgeInvalidatedArchives - Time elapsed: 0.001s
Piwik\Plugins\PrivacyManager\Tasks.deleteReportData - Time elapsed: 0.005s
Piwik\Plugins\PrivacyManager\Tasks.deleteLogData - Time elapsed: 0.000s
Piwik\Plugins\CorePluginsAdmin\Tasks.clearAllCacheEntries - Time elapsed: 0.001s
Piwik\Plugins\CorePluginsAdmin\Tasks.sendNotificationIfUpdatesAvailable - Time elapsed: 0.614s
Piwik\Plugins\CoreAdminHome\Tasks.optimizeArchiveTable - Time elapsed: 1.757s
Piwik\Plugins\CoreUpdater\Tasks.sendNotificationIfUpdateAvailable - Time elapsed: 0.001s

****************************
  Scheduled Tasks executed
****************************

@mnapoli
Copy link
Contributor

mnapoli commented Mar 10, 2015

You can go in the "System Check" in the administration panel of Piwik.

@sirtet
Copy link
Author

sirtet commented Mar 11, 2015

Ah thanks, removing execute from the console sript, i saw the file integrity check fail. No other problems are listed after fixing the execute. Thanks.

Back to cron's not running:

my log currently looks like this:

INFO Piwik\Tracker\ScheduledTasksRunner[2015-03-10 16:47:31] [76ecc] ---------------------------
INFO Piwik\Tracker\ScheduledTasksRunner[2015-03-10 16:47:31] [76ecc] INIT
INFO Piwik\Tracker\ScheduledTasksRunner[2015-03-10 16:47:31] [76ecc] Piwik is installed at: https://www.paddlershop.ch/admin/piwik/index.php
INFO Piwik\Tracker\ScheduledTasksRunner[2015-03-10 16:47:31] [76ecc] Running Piwik 2.11.2 as Super User
INFO Piwik\Tracker\ScheduledTasksRunner[2015-03-10 16:47:32] [76ecc] ---------------------------
INFO Piwik\Tracker\ScheduledTasksRunner[2015-03-10 16:47:32] [76ecc] SCHEDULED TASKS
INFO Piwik\Tracker\ScheduledTasksRunner[2015-03-10 16:47:32] [76ecc] Starting Scheduled tasks...
INFO Piwik\Tracker\ScheduledTasksRunner[2015-03-10 16:47:32] [76ecc] task,output
  Piwik\Plugins\ExamplePlugin\Tasks.myTask,Time elapsed: 0.000s
  Piwik\Plugins\ExcludeByDDNS\Tasks.updateIPs,Time elapsed: 0.057s
INFO Piwik\Tracker\ScheduledTasksRunner[2015-03-10 16:47:32] [76ecc] done
INFO Piwik\Tracker\ScheduledTasksRunner[2015-03-10 16:47:32] [76ecc] ---------------------------

@mattab
Copy link
Member

mattab commented Apr 8, 2015

@sirtet from the log you pasted, it looks like the scheduled tasks are running. I'm closing as it looks OK. if you have a problem still with latest Piwik release, feel free to reopen or create new issue

@mattab mattab closed this as completed Apr 8, 2015
@mattab mattab added the answered For when a question was asked and we referred to forum or answered it. label Apr 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

3 participants