Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Ubuntu cron cannot schedule several launches inside one minute by itself. Cron examines entries once per minute, so the reliable pattern is to schedule a wrapper every minute and let that wrapper invoke the PHP command repeatedly with controlled sleep delays. Use the PHP command-line interface (CLI), absolute paths, explicit environment settings, logging, and a lock so a slow run cannot collide with the next one.

What cron can and cannot do

A crontab entry has five time fields: minute, hour, day of month, month, and day of week. The minute field accepts values from 0 through 59, and Ubuntu documents that cron(8) examines cron entries every minute. Therefore, cron’s native resolution is one minute; syntax such as a seconds field or a sub-minute interval is not available in a standard Ubuntu crontab.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Requirement Suitable approach What to expect
Run at a whole-minute cadence Crontab schedule alone Reliable minute-based launches, such as every 10 minutes
Run several times within each minute Per-minute cron entry plus a shell wrapper Approximate spacing controlled by the wrapper and the job’s runtime
Strict timing, durable retries, or high throughput Supervised worker, queue consumer, or service architecture More lifecycle control, but more deployment and monitoring work

For example, */10 * * * * runs when the minute is divisible by 10: 00, 10, 20, 30, 40, and 50. It does not mean “wait 10 minutes after the previous launch.” Likewise, Ubuntu warns that 0/35 means minute 0 and minute 35 of every hour, not a continuous 35-minute interval across hour boundaries. Minute-step syntax is useful only for whole-minute schedules.

The recommended design: one cron launch, several PHP invocations

Put the repetition logic in a versioned, executable wrapper. Cron starts that wrapper at the beginning of each minute; the wrapper calls PHP, waits, and calls it again. This keeps the crontab readable and gives you a place to set paths, logging, error handling, and locking.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.

A minimal crontab entry is:

* * * * * /usr/local/bin/run-php-job.sh >> /var/log/php-job.log 2>&1

The schedule means “once each minute.” The wrapper determines how many times the job is attempted during that minute. Four attempts at approximately 15-second intervals are a common example, but the correct count and delay depend on the job’s runtime and acceptable load.

Build a wrapper for a four-times-per-minute job

1. Confirm PHP CLI as the cron user

Run these commands while logged in as the Unix account that will own the crontab:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
command -v php
php -v
php --ini

The first command shows the executable selected by the interactive shell. php -v confirms that the CLI binary starts, and php --ini displays the configuration files used by CLI PHP. Cron has a smaller environment than an interactive login, so record the absolute PHP path, commonly /usr/bin/php, rather than relying on PATH.

PHP’s CLI SAPI is intended for shell applications. Both forms below execute a script without making an HTTP request:

/usr/bin/php /srv/app/job.php
/usr/bin/php -f /srv/app/job.php

2. Create the wrapper at an absolute path

Create /usr/local/bin/run-php-job.sh with content similar to this:

#!/bin/sh
set -u

PHP=/usr/bin/php
JOB=/srv/app/job.php
INTERVAL=15
ATTEMPTS=4

n=1
while [ "$n" -le "$ATTEMPTS" ]; do
    "$PHP" "$JOB"
    if [ "$n" -lt "$ATTEMPTS" ]; then
        sleep "$INTERVAL"
    fi
    n=$((n + 1))
done

Replace both paths with locations on your server. This example starts immediately, then waits 15 seconds between attempts, producing up to four starts in the minute. The spacing is approximate: if PHP takes five seconds, the next start occurs about 20 seconds after the previous start because the sleep begins after the process exits. If you need a different policy, change INTERVAL, ATTEMPTS, or the loop itself.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth

Make the file executable and inspect it:

sudo install -m 0755 /path/to/run-php-job.sh /usr/local/bin/run-php-job.sh
ls -l /usr/local/bin/run-php-job.sh

Keep the script’s working directory and all application paths explicit. A cron process may start in an unexpected directory, so a relative path that worked in a terminal can fail under cron.

3. Decide what a failure should do

The simple wrapper above continues to the next scheduled attempt even if PHP exits with a nonzero status. That is appropriate when each invocation is independent and failures are logged. If one failure should stop the remaining attempts, add a check:

if ! "$PHP" "$JOB"; then
    exit 1
fi

Do not silently choose a policy. For a retryable task, you may want to record the error and continue; for a dependent sequence, aborting may prevent harmful follow-on work. Whichever policy you choose, make the exit status visible in the log.

Install and verify the crontab entry

Per-user crontab

Edit the crontab belonging to the account that should execute the job:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
crontab -e

Add:

* * * * * /usr/local/bin/run-php-job.sh >> /var/log/php-job.log 2>&1

Review the installed entries with:

crontab -l

A user crontab runs as its owner. Ensure that this account can read the PHP file, write any application data, and append to the selected log. A log under /var/log commonly requires a directory or file permission arrangement prepared by an administrator. If the account cannot write there, choose a writable application log path or create the file with suitable ownership.

System-wide cron files

/etc/crontab and files in /etc/cron.d/ contain an additional username field. The equivalent entry is therefore shaped like:

Rank #3
Sale
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black | LED mouse pad with 14 lighting modes, covers keyboard & mouse, anti-slip rubber base, waterproof surface, USB powered
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
* * * * * appuser /usr/local/bin/run-php-job.sh >> /var/log/php-job.log 2>&1

Do not copy that username column into a per-user crontab; doing so changes the field count and prevents the intended schedule.

Make cron’s environment explicit

Cron commands run through /bin/sh unless the crontab sets another SHELL. They do not automatically inherit everything from your interactive shell: PATH, HOME, the working directory, language settings, credentials, and application variables can differ. Set what the job needs in the wrapper or crontab, and use absolute paths.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For example, a crontab can define safe defaults before the schedule:

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOME=/home/appuser
APP_ENV=production

* * * * * /usr/local/bin/run-php-job.sh >> /var/log/php-job.log 2>&1

For secrets, prefer the application’s existing protected configuration mechanism rather than placing credentials in a world-readable crontab. If the PHP program expects a current directory, have the wrapper change to it explicitly with cd /srv/app || exit 1 before invoking PHP.

Unredirected output may be handed to the local mail system. Redirect both standard output and standard error, as shown above, so diagnostics are retained in a known log and do not depend on local mail configuration.

Prevent overlapping executions

Sub-minute scheduling creates overlap risk. If one invocation takes longer than its interval, the next invocation can begin while the previous one is still modifying the same records or files. Choose an explicit policy: skip a busy run, queue it, or allow concurrency only when the application is designed for it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

Shell lock with flock

To skip an invocation while another copy holds the lock, wrap the PHP command:

flock -n /run/user/<uid>/php-job.lock -c '/usr/bin/php /srv/app/job.php'

Replace <uid> with the numeric user ID and ensure that the directory exists and is writable by that user. In a wrapper, a failed nonblocking lock should be logged as a skipped attempt rather than treated as a mysterious PHP failure. Every competing invocation must use the same lock file and convention.

A wrapper fragment that continues its minute loop while skipping a busy job can look like:

LOCK=/run/user/1000/php-job.lock

if flock -n "$LOCK" -c "$PHP $JOB"; then
    :
else
    echo "$(date -u '+%Y-%m-%dT%H:%M:%SZ') job already running; skipped" >&2
fi

When command arguments contain spaces or shell metacharacters, avoid assembling an untrusted command string. Use a dedicated lock descriptor or a small PHP lock wrapper instead.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

PHP’s flock()

PHP can enforce the lock inside the application:

<?php
$lockPath = '/srv/app/job.lock';
$fp = fopen($lockPath, 'c');
if ($fp === false) {
    fwrite(STDERR, "Cannot open lock filen");
    exit(1);
}

if (!flock($fp, LOCK_EX | LOCK_NB)) {
    fwrite(STDERR, "Another invocation is running; skippingn");
    fclose($fp);
    exit(0);
}

try {
    // Job work goes here.
} finally {
    flock($fp, LOCK_UN);
    fclose($fp);
}

PHP documents flock() as an advisory lock. It works only when every cooperating process honors the same lock. A program that ignores the lock can still modify the same data, so locking is not a substitute for database transactions or application-level idempotency.

Logging, rotation, and observability

The cron line’s >> appends output and 2>&1 combines errors with normal output. Include timestamps and meaningful exit messages in the wrapper or PHP application so you can distinguish a skipped lock, a PHP startup error, and a successful run.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

Because a four-times-per-minute loop can write frequently, arrange log rotation appropriate to the host. A rotation rule should preserve ownership and permissions, signal or restart any process that keeps an open file descriptor when required, and retain enough history to diagnose failures. Do not assume that adding redirection alone solves disk growth.

After installation, check both the system’s cron logging and the application log. On systems using a journal, query the service logs with the host’s normal journal tooling; on systems using a traditional cron log, inspect the configured cron log file. The exact location varies by Ubuntu release and logging configuration, so verify it on the target host rather than hard-coding one path in your procedure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Test exactly as cron will run it

  1. Switch to the crontab owner: sudo -u appuser -H sh (or log in as that account).
  2. Run the absolute command manually: /usr/local/bin/run-php-job.sh.
  3. Check the PHP exit status with echo $? and inspect all files the job should create or update.
  4. Confirm that the user can read the script, write its data directories, open the lock file, and append to the log.
  5. Wait for a scheduled minute, then inspect the cron and application logs for the expected number of attempts.

Manual success from a login shell does not prove cron success. Compare the environments if behavior differs: executable paths, HOME, current directory, PHP configuration, permissions, and required variables are the usual causes.

Common failure modes and fixes

Symptom Likely cause Fix
No execution at all Malformed crontab, wrong file type, or missing execute permission Run crontab -l, validate the five fields (plus username only in system-wide files), and use chmod or install -m 0755.
“php: not found” Cron’s PATH differs from the terminal’s Use the absolute path from command -v php, such as /usr/bin/php.
Script works manually but not under cron Relative paths, missing variables, different HOME, or permissions Set the environment explicitly, use absolute paths, and test as the crontab owner.
Multiple processes modify the same data Job duration exceeds the interval and no shared lock exists Add a common flock or PHP flock() convention, or redesign for queueing.
Only the first attempt runs Wrapper exits on an error or receives a termination signal Inspect the log and exit status; choose deliberately between aborting, logging and continuing, and retrying.
Log file grows without bound Frequent output with no rotation Configure rotation and retain an appropriate history.
Lock is always unavailable Stale path, wrong ownership, or another legitimate long-running process Verify the directory, permissions, lock path, and process list; do not delete a lock blindly while a job may still be running.

Choose the right scheduler for the workload

Cron plus a sleep loop

This is the smallest change for a lightweight PHP task on an Ubuntu host that is already running continuously. It is easy to inspect, requires no daemon beyond cron, and works well when approximate sub-minute spacing is acceptable. Its weaknesses are process-start overhead, limited lifecycle supervision, and timing drift when the job duration varies.

A persistent worker or supervised service

A long-running worker can keep PHP initialized, reduce repeated startup overhead, and implement queues, retries, graceful shutdown, and durable state. A service manager can restart it after failure and make startup behavior explicit. This adds deployment, monitoring, and release complexity, so it is better justified when the workload is frequent, latency-sensitive, or mission-critical.

Systemd timer or another queue architecture

A timer can express calendar-based activation and pair with a service unit, while a queue worker can separate task production from task execution. Neither option changes the need to define overlap, retry, and durability behavior. Select them when those operational controls matter more than cron’s simplicity.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Design checklist

  • Use a per-minute cron entry; do not expect cron syntax to provide seconds.
  • Invoke the PHP CLI with an absolute executable and script path.
  • Set the working directory and required environment explicitly.
  • Choose the number of attempts and delay based on actual job runtime and load.
  • Decide whether a failed attempt aborts, retries, or is logged and skipped.
  • Prevent unsafe overlap with a shared advisory lock or an application design that supports concurrency.
  • Redirect standard output and standard error, and rotate the resulting log.
  • Install the entry with crontab -e, verify with crontab -l, and test as the cron user.
  • Move to a supervised worker or service when strict timing, durable retries, restart recovery, or high throughput is required.

Final answer

To run a PHP job several times per minute on Ubuntu, schedule a wrapper with * * * * * and let the wrapper call /usr/bin/php repeatedly with controlled sleeps. Cron supplies the once-per-minute trigger; the wrapper supplies sub-minute repetition. Absolute paths, explicit environment variables, complete logging, and a shared lock turn the basic loop into an operation that is predictable and diagnosable.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.