Opened 5 years ago
Closed 5 years ago
#49327 closed enhancement (worksforme)
Add a function that identifies whether WordPress is doing a cron
Reported by: | pikamander2 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.8 |
Component: | Cron API | Keywords: | |
Focuses: | Cc: |
Description
Ideally, there would be three possible return values:
- A value that indicates that no cron is being performed
- A value that indicates that a WP_CRON is being performed
- A value that indicates that a cron is being performed via the CLI
This would mostly be helpful for logging purposes. For example, some hosts use a setup in which crons are run by a different user than normal (apache, root, www-data, etc), which can affect things like your environment variables and file permissions.
Even though it's not strictly necessary, it would be helpful to have it as an option.
Change History (1)
Note: See
TracTickets for help on using
tickets.
Hiya,
There's actually a way to do this already, either with the function wp_doing_cron() (recommended), or looking for the constant
DOING_CRON
and seeing if it'strue
.As for if it's being performed via CLI, that can be done by looking at the PHP native function php_sapi_name(), you'll see
cli
as the output if it's on the command line.Since these options already exist, I'm going to mark this ticket as
closed
, but if you feel there's something that could be done better, please do follow up in here, as it's just a task-management status, and conversations can still continue.