Snippet. PHP. Execute Pseudocron Job After Web Page Has Loaded

This PHP snippet shows how to execute a repetitive job, even if we don't have access to cron.

If your server does not support cron jobs, then you may need to use another way to replace the shortcoming. This is usually called pseudo cron. The snippet bellow shows how to call the pseudo cron script after the webpage has loaded. The snippet uses the JQuery library and Ajax to call the pseudo cron.

<script type="text/javascript">
    $(window).bind("load", function(){$.get("cron.php",function(data){})});
</script>

Updated on: 23 Nov 2024