WP Crontrol

Beskrivning

Med WP Crontrol kan du se och styra vad som händer i systemet för WP-Cron. Från adminskärmarna kan du:

  • Se alla cron-händelser tillsammans med deras argument, schemaläggning, återanrops-funktioner och när de ska köras nästa gång.
  • Edit, delete, pause, resume, and immediately run cron events.
  • Lägg till nya Cron-händelser.
  • Massborttagning av Cron-händelser.
  • Lägg till, redigera och ta bort anpassade Cron-scheman.
  • Export and download cron event lists as a CSV file.

WP Crontrol is aware of timezones, will alert you to events that have no actions or that have missed their schedule, and will show you a helpful warning message if it detects any problems with your cron system.

Användning

  1. Gå till menyn Verktyg Cron-händelser för att hantera Cron-händelser.
  2. Gå till menyn Inställningar Cron-scheman för att hantera Cron-scheman.

Andra tillägg

Jag underhåller flera andra tillägg för utvecklare. Kolla in dem:

  • Query Monitor är panelen för utvecklarverktyg för WordPress.
  • User Switching gör det möjligt att omedelbart växla mellan användarkonton i WordPress.

Skärmdumpar

  • Cron events can be modified, deleted, and executed

  • Nya cron-händelser kan läggas till

  • Nya Cron-scheman kan läggas till, vilket ger tilläggsutvecklare fler alternativ när de schemalägger händelser

Vanliga frågor

Fungerar detta tillägg med PHP 8?

Ja, det är aktivt testat och fungerar upp till PHP 8.1.

I get the error ”There was a problem spawning a call to the WP-Cron system on your site”. How do I fix this?

You can read all about problems spawning WP-Cron here.

Varför missar vissa cron-händelser sitt schema?

You can read all about cron events that miss their schedule here.

Varför dyker vissa cron-händelser upp igen kort efter att jag tagit bort dem?

If the event is added by a plugin then the plugin most likely rescheduled the event as soon as it saw that the event was missing. To get around this you can instead use the ”Pause” option for the event which means it’ll remain in place but won’t perform any action when it runs.

Är det säkert att ta bort cron-händelser?

This depends entirely on the event. You can use your favourite search engine to search for the event name in order to find out which plugin it belongs to, and then decide whether or not to delete it.

If the event shows ”None” as its action then it’s usually safe to delete. Please see the other FAQs for more information about events with no action.

Varför kan jag inte ta bort några cron-händelser?

The WordPress core software uses cron events for some of its functionality and removing these events is not possible because WordPress would immediately reschedule them if you did delete them. For this reason, WP Crontrol doesn’t let you delete these persistent events from WordPress core in the first place.

Om du inte vill att dessa händelser ska köras kan du ”pausa” dem istället.

What happens when I pause an event?

Pausing an event will disable all actions attached to the event’s hook. The event itself will remain in place and will run according to its schedule, but all actions attached to its hook will be disabled. This renders the event inoperative but keeps it scheduled so as to remain fully compatible with events which would otherwise get automatically rescheduled when they’re missing.

As pausing an event actually pauses its hook, all events that use the same hook will be paused or resumed when pausing and resuming an event. This is much more useful and reliable than pausing individual events separately.

What happens when I resume an event?

Resuming an event re-enables all actions attached to the event’s hook. All events that use the same hook will be resumed.

What does it mean when ”None” is shown for the Action of a cron event?

This means the cron event is scheduled to run at the specified time but there is no corresponding functionality that will be triggered when the event runs, therefore the event is useless.

This is often caused by plugins that don’t clean up their cron events when you deactivate them. You can use your favourite search engine to search for the event name in order to find out which plugin it belongs to, and then decide whether or not to delete it.

How do I change the next run time or the recurrence of a cron event?

You can change the time and recurrence of a cron event by clicking the ”Edit” link next to the event.

Hur kan jag skapa en cron-händelse som begär en URL?

From the Tools → Cron Events → Add New screen, create a PHP cron event that includes PHP that fetches the URL using the WordPress HTTP API. For example:

wp_remote_get( 'http://example.com' );

Please see the ”Which users can manage PHP cron events?” FAQ for information about which users can create PHP cron events.

Why do changes that I make to some cron events not get saved?

You can read all about problems with editing cron events here.

Kan jag exportera en lista över cron-händelser?

Yes, a CSV file of the event list can be exported and downloaded via the ”Export” button on the cron event listing screen. This file can be opened in any spreadsheet application.

Can I see a historical log of all the cron events that ran on my site?

Inte än, men jag hoppas kunna lägga till denna funktion snart.

Kan jag se en logghistorik med ändringar, tillägg och borttagningar av cron-händelser och -scheman?

Yes. The excellent Simple History plugin has built-in support for logging actions performed via WP Crontrol.

Vad är nyttan med att lägga till nya Cron-scheman?

Cron schedules are used by WordPress and plugins for scheduling events to be executed at regular intervals. Intervals must be provided by the WordPress core or a plugin in order to be used. As an example, many backup plugins provide support for periodic backups. In order to do a weekly backup, a weekly cron schedule must be entered into WP Crontrol first and then a backup plugin can take advantage of it as an interval.

Hur skapar jag en ny Cron-händelse?

There are two steps to getting a functioning cron event that executes regularly. The first step is telling WordPress about the hook. This is the part that WP Crontrol was created to provide. The second step is calling a function when your hook is executed.

Steg ett: lägga till åtgärds-hooken

In the Tools → Cron Events admin panel, click on ”Add New” and enter the details of the hook. You’re best off using a hook name that conforms to normal PHP variable naming conventions. The event schedule is how often your hook will be executed. If you don’t see a good interval, then add one in the Settings → Cron Schedules admin panel.

Steg två: skriva funktionen

This part takes place in PHP code (for example, in the functions.php file from your theme). To execute your hook, WordPress runs an action. For this reason, we need to tell WordPress which function to execute when this action is run. The following line accomplishes that:

add_action( 'my_hookname', 'my_function' );

Nästa steg är att skriva din funktion. Här är ett enkelt exempel:

function my_function() {
    wp_mail( 'hello@example.com', 'WP Crontrol', 'WP Crontrol rocks!' );
}

Hur skapar jag en ny PHP Cron-händelse?

In the Tools → Cron Events admin panel, click on ”Add New”. In the form that appears, select ”PHP Cron Event” and enter the schedule and next run time. The event schedule is how often your event will be executed. If you don’t see a good interval, then add one in the Settings → Cron Schedules admin panel. In the ”Hook code” area, enter the PHP code that should be run when your cron event is executed. You don’t need to provide the PHP opening tag (<?php).

Please see the ”Which users can manage PHP cron events?” FAQ for information about which users can create PHP cron events.

Vilka användare kan hantera Cron-händelser och scheman?

Only users with the manage_options capability can manage cron events and schedules. By default, only Administrators have this capability.

Which users can manage PHP cron events? Is this dangerous?

Only users with the edit_files capability can manage PHP cron events. This means if a user cannot edit files on the site (eg. through the Plugin Editor or Theme Editor) then they cannot edit or add a PHP cron event. By default, only Administrators have this capability, and with Multisite enabled only Super Admins have this capability.

If file editing has been disabled via the DISALLOW_FILE_MODS or DISALLOW_FILE_EDIT configuration constants then no user will have the edit_files capability, which means editing or adding a PHP cron event will not be permitted.

Therefore, the user access level required to execute arbitrary PHP code does not change with WP Crontrol activated.

Är några WP-CLI-kommandon tillgängliga?

The cron commands which were previously included in WP Crontrol are now part of WP-CLI itself. See wp help cron for more info.

Vem tog bilden i tilläggets sidhuvud?

The photo was taken by Michael Pardo and is in the public domain.

Recensioner

26 september 2022
Ein super Plugin, dass die Cron Jobs übersichtlich auflistet.
5 september 2022
This plugin uses the default WP Cron system which has limitations. Those limitations prevented it from being the magic cron plugin I need for specific tasks, but the plugin author has documented those issues, provided alternative solutions, and responded to the support topic very quickly even though it wasn't a problem with the plugin itself. The plugin may not have fit my needs, but it is a solid plugin with good support, and those are the primary rating factors for me to determine a good/bad plugins.
31 juli 2022
Nice idea but not a good plugin to install and forget. This plugin crashed 5 of my websites and although it had an update to fix the issue, we have had to discontinue it on all our sites.
12 juli 2022 4 svar
As everybody else say: This plugin was great, but after releasing an automatic update with a fatal error, about 200 000 sites world-wide went down - among others some of our customers'. We have no reason to think that this was intentional, but nonetheless it's unacceptable, and there's nothing that says this developer won't do this again. Do not install.
Läs alla 136 betyg

Bidragsgivare och utvecklare

”WP Crontrol” är programvara med öppen källkod. Följande personer har bidragit till detta tillägg.

Bidragande personer

”WP Crontrol” har översatts till 17 språk. Tack till översättarna för deras bidrag.

Översätt ”WP Crontrol” till ditt språk.

Intresserad av programutveckling?

Läs programkoden, kika på SVN-filförvaret eller prenumerera på utvecklarloggen via RSS.

Ändringslogg

1.15.0

  • Introducerar möjligheten att pausa och återstarta cron-händelser från listvyn med händelser, se ”Vanliga frågor” för fullständig information
  • Adds the site time to the cron event editing screen
  • Implements an autoloader to reduce memory usage
  • Höjer den lägsta PHP-versionen som stöds till 5.6

1.14.0

  • Reverts the changes introduced in version 1.13 while I look into the problem with the deployment process for wordpress.org

1.13.2

  • Fixes another issue with missing files in the release

1.13.1

  • Åtgärdar ett problem med saknade filer i 1.13.0-utgåvan

1.13.0

  • Introducerar möjligheten att pausa och återstarta cron-händelser från listvyn med händelser, se ”Vanliga frågor” för fullständig information
  • Implements an autoloader to reduce memory usage
  • Höjer den lägsta PHP-versionen som stöds till 5.6

1.12.1

  • Corrects an issue where an invalid hook callback isn’t always identified
  • Various code quality improvements

1.12.0

  • Fix the PHP cron event management.
  • More ”namespacing” of query variables to avoid conflicts with other cron management plugins.

1.11.0

  • Introduced an Export feature to the event listing screen for exporting the list of events as a CSV file.
  • Added the timezone offset to the date displayed for events that are due to run after the next DST change, for extra clarity.
  • Introduced the crontrol/filter-types and crontrol/filtered-events filters for adjusting the available event filters on the event listing screen.
  • Lots of code quality improvements (thanks, PHPStan!).

1.10.0

  • Support for more granular cron-related error messages in WordPress 5.7
  • Several accessibility improvements
  • Warning for events that are attached to a schedule that is too frequent
  • More clarity around events and schedules that are built in to WordPress core
  • Add a Help tab with links to the wiki and FAQs

1.9.1

  • Fix the adding of new cron events when DISALLOW_FILE_EDIT is true.

1.9.0

  • Add filters and sorting to the event listing screen. Props @yuriipavlov.
  • Replace the ”Add New” tabs with a more standard ”Add New” button on the cron event listing page.
  • Switch back to using browser-native controls for the date and time inputs.
  • Add an error message when trying to edit a non-existent event.
  • Introduce an informational message which appears when there are events that have missed their schedule.
  • Fire actions when cron events and schedules are added, updated, and deleted.

1.8.5

  • Fix an issue with the tabs in 1.8.4.

1.8.4

  • Add a warning message if the default timezone has been changed. More information.
  • Fixed string being passed to strtotime() function when the Now option is chosen when adding or editing an event.

1.8.3

  • Fix the editing of events that aren’t currently listed on the first page of results.

1.8.2

  • Bypass the duplicate event check when manually running an event. This allows an event to manually run even if it’s due within ten minutes or if it’s overdue.
  • Force only one event to fire when manually running a cron event.
  • Introduce polling of the events list in order to show a warning when the event listing screen is out of date.
  • Add a warning for cron schedules which are shorter than WP_CRON_LOCK_TIMEOUT.
  • Add the Site Health check event to the list of persistent core hooks.

1.8.1

  • Fix the bottom bulk action menu on the event listing screen.
  • Make the timezone more prominent when adding or editing a cron event.

1.8.0

  • Searching and pagination for cron events
  • Ability to delete all cron events with a given hook
  • More accurate response messages when managing events (in WordPress 5.1+)
  • Visual warnings for events without actions, and PHP events with syntax errors
  • Timezone-related clarifications and fixes
  • A more unified UI
  • Modernised codebase

1.7.1

  • Correct the PHP.net URL for the strtotime() reference.

1.7.0

  • Remove the date and time inputs and replace with a couple of preset options and a plain text field. Fixes #24 .
  • Ensure the schedule name is always correct when multiple schedules exist with the same interval. Add error handling. Fixes #25.
  • Re-introduce the display of the current site time.
  • Use a more appropriate HTTP response code for unauthorised request errors.

1.6.2

  • Remove the ability to delete a PHP cron event if the user cannot edit files.
  • Remove the Edit link for PHP cron events when the user cannot edit the event.
  • Avoid a PHP notice due to an undefined variable when adding a new cron event.

1.6.1

  • Fix a potential fatal error on the cron events listing screen.

1.6

  • Introduce bulk deletion of cron events. Yay!
  • Show the schedule name instead of the schedule interval next to each event.
  • Add core’s new delete_expired_transients event to the list of core events.
  • Don’t allow custom cron schedules to be deleted if they’re in use.
  • Add links between the Events and Schedules admin screens.
  • Add syntax highlighting to the PHP code editor for a PHP cron event.
  • Styling fixes for events with many arguments or long arguments.
  • Improvements to help text.
  • Remove usage of create_function().
  • Fix some translator comments, improve i18n, improve coding standards.

1.5.0

  • Show the hooked actions for each cron event.
  • Don’t show the Delete link for core’s built-in cron events, as they get re-populated immediately.
  • Correct the success message after adding or editing PHP cron events.
  • Correct the translations directory name.

1.4

  • Switch to requiring cron event times to be input using the site’s local timezone instead of UTC.
  • Add the ability for a PHP cron event to be given an optional display name.
  • Better UX for users who cannot edit files and therefore cannot add or edit PHP cron events.
  • Terminology and i18n improvements.

1.3.1

  • Display a less scary looking message when DISABLE_WP_CRON is defined.
  • Correct the example code for cron event arguments.

1.3

  • Förbättringar i användargränssnittet.
  • More error detection when testing WP-Cron functionality.
  • Improve the capability checks for single site and multisite.
  • Lots of escaping and sanitising.
  • Fix various issues with multiple events with the same hook name.
  • Removed the WP-CLI commands, as these have now been added to WP-CLI core (see wp help cron for more info)

1.2.3

  • Tweaks to i18n and date and args formatting
  • Properly escape the crontrol_message query var (props Julio Potier)

1.2.2

  • Added wp crontrol run-event and wp crontrol delete-event WP-CLI commands
  • Clarify language regarding hooks/entries/events