If you want to execute the same snippet of code, you might refactor it into a separate function, and call it from both `mymodule_form_submit` and `mymodule_cron`. Something like the following: function _mymodule_set_expiry_date() { db_insert('bds_user_expiry')->fields(array( 'uid' =>$user_id, 'active_user'=>strtotime("now"), ))->execute(); drupal_set_message(t('You have successfully set the expiry date')); } And then, on your hooks: function mymodule_form_submit($form, $form_state) { _mymodule_set_expiry_date(); // ... rest of your code } function mymodule_cron() { _mymodule_set_expiry_date(); // ... rest of your code } You can see the following question on Drupal Answers for a more detailed explanation about `hook_cron` and `hook_cron_queue_info`: https://drupal.stackexchange.com/questions/69332/how-to-use-hook-cron-queue-info-in-a-custom-module Hope that helps,