Title: Cron inside a plugin
Last modified: August 21, 2016

---

# Cron inside a plugin

 *  [dshaner](https://wordpress.org/support/users/dshaner/)
 * (@dshaner)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/cron-inside-a-plugin/)
 * Hello, I am working on a plugin that imports data every hour if there are new
   files to process. I am trying to use wp_schedule_event and it does not fire the
   function.
 *     ```
       /**
        * Plugin activation
        */
        function gpi_saxo_activation() {
       	wp_schedule_event( time(), 'hourly', 'gpi_saxotech_import');
       }
       register_activation_hook(__FILE__, 'gpi_saxo_activation');
       add_action('gpi_saxotech_import', 'gpi_hourly_import');
   
       /**
        * Plugin deactivation
        */
       function gpi_saxo_deactivation() {
       	wp_clear_scheduled_hook('gpi_saxotech_import');
       }
       register_deactivation_hook(__FILE__, 'gpi_saxo_deactivation');
   
       /**
        * GPI hourly import
        */
       function gpi_hourly_import() {
       	$xml_files = '';
       	//$xml_files = gpi_get_all_files();
   
       	if($xml_files) {
       		//$parsed = gpi_parse_xml($xml_files);
       		wp_create_category('Successfully created XML file');
       	} else {
       		wp_create_category('WFailure to create XML file');
       	}
       }
       ```
   
 * Can someone give me an idea to what is wrong?

Viewing 1 replies (of 1 total)

 *  [Rene Skou](https://wordpress.org/support/users/amras/)
 * (@amras)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/cron-inside-a-plugin/#post-4255673)
 * Hi dshaner
 * If no one visit your site then the wp cron job will not get fired, to setup a
   real cron job, you need to set it up at server level.
 * This article describes how to setup a cron job [http://tommcfarlin.com/wordpress-cron-jobs/](http://tommcfarlin.com/wordpress-cron-jobs/)

Viewing 1 replies (of 1 total)

The topic ‘Cron inside a plugin’ is closed to new replies.

## Tags

 * [automation](https://wordpress.org/support/topic-tag/automation/)
 * [cron](https://wordpress.org/support/topic-tag/cron/)
 * [Import](https://wordpress.org/support/topic-tag/import/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 2 participants
 * Last reply from: [Rene Skou](https://wordpress.org/support/users/amras/)
 * Last activity: [12 years, 8 months ago](https://wordpress.org/support/topic/cron-inside-a-plugin/#post-4255673)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
