how to execute a php file after every half n hour without using schedular (cron jobs).
i need to upload pdf files automatically from system to server after every half n hour.but without using cron jobs.Please help
how to execute a php file after every half n hour without using schedular (cron jobs).
i need to upload pdf files automatically from system to server after every half n hour.but without using cron jobs.Please help
Two different problems are mixed into this thread: running a PHP job on the server every 30 minutes, and moving PDFs from a local PC to the server every 30 minutes. Picking the right approach depends on where the files live and what you can run: a server-side PHP pseudo-cron is fine if the server can reach the files, but if the PDFs sit on your local machine the most reliable solution is a small uploader that pushes files to the server. This note ties together the suggestions already posted by , and and shows a safe, practical pattern you can apply.
If you must avoid server cron and want the server to perform a periodic task when it gets traffic, use a “triggered-by-request” guard: store the last-run timestamp, acquire an exclusive lock to prevent overlap, check the interval and then run your worker. Put the logic on a lightweight URL (or include it from a commonly-requested page). Example (place in a public PHP script that is invoked regularly):
<?php
$stamp = __DIR__ . '/.last_run';
$lock = __DIR__ . '/.last_run.lock';
$now = time();
// non-blocking exclusive lock to avoid simultaneous runs
$fp = fopen($lock, 'c');
if (!$fp || !flock($fp, LOCK_EX | LOCK_NB)) { if ($fp) fclose($fp); exit; }
$last = @file_get_contents($stamp);
if (($now - (int)$last) < 1800) { flock($fp, LOCK_UN); fclose($fp); exit; }
// claim the run immediately
file_put_contents($stamp, (string)$now, LOCK_EX);
// do the work in a separate file; keep it short and idempotent
include __DIR__ . '/cron_worker.php';
flock($fp, LOCK_UN);
fclose($fp); If the PDFs are on your local PC, run an uploader/agent that watches the folder and pushes files (SFTP or HTTPS POST) as they appear — this avoids relying on any server scheduler. Best practices for either approach: use secure transport (SFTP/HTTPS), upload to a temporary filename then rename on the server to avoid partial files, add retries with exponential backoff, log failures, and protect any public trigger with a secret token or IP restrictions. For safety, make your worker idempotent (skip already-processed files) and keep credentials out of code (use key files or OS credential storage).
If you share which OS the local machine uses and whether you can run background processes there, a short example uploader script and a secure server-side receive-handler can be provided.
Jump to Post— rereus 0If you have a page with web trafic you can add code to write timestamp in a file and test if is older than 30 minutes to do the job and rewrite timestamp (first).
Jump to Post— almostbob 866upload from the local system does not need a cron job at the server
local system task scheduler to start an ftp client will do it
If you have a page with web trafic you can add code to write timestamp in a file and test if is older than 30 minutes to do the job and rewrite timestamp (first).
Why not CRON jobs etc? PHP isn't really meant for this kind of task. Executing something regularly would normally be done using something like a CRON job or something like an application running in the background.
upload from the local system does not need a cron job at the server
local system task scheduler to start an ftp client will do it
i need to upload pdf files from a local sys directory to server directory ....automatically after every half n hour. Please give me some steps and code help
check the helpscreens for the ftp program of preference
(ftp, filezilla, cuteftp, all have startup parameters that can connect to server, synchronize folders, exit. I assume that all do.)
Add that to the task scheduler with a half hour schedule, using guidance from the helpscreens to task scheduler.
But you say than you want execute a php file, what do this file?
where is it?
I use filezilla and don't find options to do that automaticaly.
I use wget or rsync to do this kind of tasks.
But you say than you want execute a php file,
No you doesnt
the op wants to schedule a file upload to synchronize a folder of pdf
and wants ideas to work with, postulates a php script
the other you, in answer says executing a php file by cron is unneccessary
what do this file? where is it?
if it is done serverside, then you he me us has to write the script another reason to use a local task
I use filezilla and don't find options to do that automaticaly.
what you read about scheduling php, is not what is written in the answer.
I use wget or rsync to do this kind of tasks.
... .. . without cron . .. ...
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.