Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › Cron

How to Use a Cron Job to Start a Prerecorded YouTube Livestream on a VPS

By Freedom251 Team · · 8 min read

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.

You can use cron to launch FFmpeg on a Linux VPS at a scheduled time and send a prerecorded file to a YouTube Live event. The steps are separate, though: cron starts the encoder, but YouTube’s documented scheduled-stream workflow may still require you to wait for the preview in Live Control Room and click Go live. Test the full sequence before relying on an unattended start.

What cron can—and cannot—automate

A prerecorded-file livestream uses an encoder feed, not a camera. YouTube supplies an ingest URL and stream key for the event; FFmpeg reads your media and sends it to that endpoint. Cron can start that FFmpeg process at a planned time. It does not, by itself, confirm that the public broadcast has started in YouTube Studio.

As an Amazon Associate I earn from qualifying purchases.

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

For a scheduled encoder stream, YouTube’s documented flow is to start the encoder, wait for its preview to appear in Live Control Room, then select Go live. A running FFmpeg process therefore is not proof that viewers can watch the event. The YouTube Live Streaming API offers programmatic broadcast and stream management, but that is a separate implementation with authentication and state management, not a cron setting. YouTube’s encoder setup instructions and Google’s broadcasts and streams documentation describe these workflows.

Before you schedule the VPS job

Enable live streaming and create the event

  1. Check that your channel is eligible to stream live and enable the feature if needed. YouTube says first-time live streaming enablement can take up to 24 hours, so do not leave this until the scheduled start is near. YouTube’s live-stream setup guidance covers the eligibility and enablement flow.

    #1 Best Overall
    Bmax Mini PC Mini Desktop Computer Intel Celeron J3355 (Up to 2.5GHz) Win 11, 6GB RAM 128GB eMMC Support M.2 SSD Expansion (512GB/2TB), 4K Dual Display WiFi5& BT5.0 for Home/Office,Daily Use,B1 Plus
    • 𝐏𝐨𝐰𝐞𝐫𝐟𝐮𝐥 & 𝐄𝐟𝐟𝐢𝐜𝐢𝐞𝐧𝐭 𝐏𝐞𝐫𝐟𝐨𝐫𝐦𝐚𝐧𝐜𝐞: Powered by the Intel Celeron J3355 Processor (up to 2.5GHz), this Mini PC delivers a 25% performance boost over previous generations. Pre-installed with Windows 11 Home and supporting Linux/Ubuntu, it’s the ideal micro desktop for seamless web browsing, document editing, and efficient daily office tasks.
    • 𝐌𝐚𝐬𝐬𝐢𝐯𝐞 𝐒𝐭𝐨𝐫𝐚𝐠𝐞 & 𝐔𝐧𝐢𝐪𝐮𝐞 𝐄𝐱𝐩𝐚𝐧𝐬𝐢𝐨𝐧: Equipped with 6GB LPDDR3 RAM and 128GB onboard storage for fast boot-ups. Stand out with our dual M.2 SSD slot design (1x SATA + 1x NVMe), allowing you to easily expand storage up to 2TB without replacing the original drive. Perfect for managing large digital libraries and intensive multitasking.
    • 𝐒𝐭𝐮𝐧𝐧𝐢𝐧𝐠 𝟒𝐊 𝐃𝐮𝐚𝐥 𝐇𝐃𝐌𝐈 𝐃𝐢𝐬𝐩𝐥𝐚𝐲: Boost your productivity with Intel HD Graphics 500 and dual HDMI ports, supporting 4K @60Hz high-definition visuals. Connect two monitors simultaneously to streamline your workflow—ideal for home office setups, stock trading, or enjoying a theater-like 4K media experience.
    • 𝐔𝐥𝐭𝐫𝐚-𝐂𝐨𝐦𝐩𝐚𝐜𝐭 & 𝐒𝐩𝐚𝐜𝐞-𝐒𝐚𝐯𝐢𝐧𝐠 𝐃𝐞𝐬𝐢𝐠𝐧: Measuring only 4.2x4.1x1.4 inches and weighing just 0.49 lbs, this palm-sized mini computer fits anywhere. Use the included VESA bracket to mount it behind your monitor for a zero-clutter workspace. Features a smart silent fan and heat sink system for quiet, reliable 24/7 operation.
    • 𝐒𝐭𝐚𝐛𝐥𝐞 𝐂𝐨𝐧𝐧𝐞𝐜𝐭𝐢𝐯𝐢𝐭𝐲 & 𝐒𝐦𝐚𝐫𝐭 𝐑𝐞𝐜𝐨𝐯𝐞𝐫𝐲: Stay connected with Dual-Band WiFi (2.4G/5G), Bluetooth 5.0, and Gigabit Ethernet. Exclusive One-Click Restore feature (via F9 key) allows for quick system recovery in minutes. Backed by Bmax's 12-month warranty and lifetime technical support for a worry-free purchase.
  2. In YouTube Studio, create or schedule a live event. Set its visibility and other event details. Scheduling gives you an event watch page that can be shared and lets viewers set reminders.

  3. Open the event’s encoder settings and copy the ingest URL and stream key. Use the values Studio provides; do not assume an endpoint format or reuse a key from another event without checking.

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

Protect the stream key

Treat the key like a password: anyone with it may be able to connect an encoder to your stream. Store it in a configuration file readable only by the account that runs the job, or another protected environment source. Do not put the real key in a public repository, a cron line, shell history, screenshots, or broadly accessible logs. If it is exposed, replace or rotate it in YouTube Studio before the event.

Prepare the VPS and media

  • Install an FFmpeg build that includes the protocols and codecs your chosen command needs. Confirm the installed version and options; FFmpeg flags and available codec support can vary by build.

  • Keep the media file on a stable, absolute path and ensure it remains accessible for the entire broadcast.

  • Check disk space, network egress and bandwidth limits, and CPU capacity. Stream-copying and transcoding have different resource needs, and there is no single VPS size suitable for every resolution, bitrate, codec, and workload.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    Rank #2
    Sale
    KAMRUI Pinova P2 Mini PC 16GB RAM 512GB SSD, AMD Ryzen 4300U(Beats 5400U/3500U/N95,Up to 3.7GHz,4C/8T) Mini Computers,Triple 4K Display/HDMI+DP+Type-C/WiFi/BT for Home/Business Mini Desktop Computers
    • 【AMD Ryzen 4300U True 4-Core CPU: Outperforms N95 & i3-10110U】KAMRUI P2 Mini PC is equipped with true 4-core AMD Ryzen 4300U processor built on advanced 7nm Zen2 architecture,This means you get consistent, unthrottled performance for hours on end, whether you’re running multiple browser tabs, streaming 4K content, or managing virtual machines. Compare that to Intel N95 (4 efficiency cores that throttle under load) or Intel i3-10110U (only 2 cores total), and the difference is night and day: The KAMRUI P2 AMD Ryzen 4300U (28W) is 40% faster than the Intel i3-10110U and 25% faster than the Intel N95 in multi-core tasks, ensuring smooth, lag-free performance even during heavy workloads.
    • 【Integrated AMD Radeon Graphics: 2.5X Stronger for Tri 4K】The KAMRUI P2 AMD 4300U Mini PC have unlocked the full potential of the built-in AMD Radeon Vega 5 graphics with 28W power delivery, making it 2.5 times stronger than the Intel UHD graphics found in the N95 and i3-10110U. This means you can enjoy Tri 4K@60Hz displays without a single stutter, perfect for productivity setups, home theaters, or even light photo/video editing and casual gaming. While the Intel N95/i3-10110U struggle to run a single 4K display without lag, The KAMRUI AMD 4300U Mini PC handles Tri 4K effortlessly, turning your workspace into a high-efficiency hub or your living room into a premium entertainment center.
    • 【Large Storage Capacity, Easy Expansion】KAMRUI Pinova P2 mini computers is equipped with 16GB LPDDR4 for faster multitasking and smooth application switching. 512GB M.2 SSD ensures fast startup, fast file transfers and plenty of storage space,eliminating slow loading times and ensuring fast responsiveness. the two storage slots (1x M.2 2280 SATA/NVMe PCIe3.0 slot, 1x M.2 2280 SATA slot) can be combined to provide up to 4TB of total storage(Not included). This gives you enough space for all your projects, media and data.
    • 【4K Triple Display】KAMRUI Pinova P2 4300U mini desktop computers is equipped with HDMI2.0 ×1 +DP1.4 ×1+USB3.2 Gen2 Type-C ×1 interfaces for faster transmission, Triple 4K@60Hz Display, KAMRUI P2 mini computer is ideal for visual home entertainment, home office, conference rooms, etc. USB3.2 Gen2 Type-A port ×2 with a transfer speed of up to 10 Gbps (21 times faster than USB 2.0) for efficient data transfer. Ideal for seamless multitasking between spreadsheets, browsers and presentations, or for an immersive entertainment experience.
    • 【USB3.2 Gen2 Type-C 10Gbps, Versatile connectivity】KAMRUI P2 mini desktop pc fast and versatile connectivity! The USB3.2 Gen2 Type-C port offers a data transfer rate of 10Gbps and simultaneously supports DisplayPort 1.4 video output. The P2 AMD Ryzen 4300U Mini PC is complemented by Gigabit LAN, WiFi and Bluetooth, so nothing stands in the way of a productive working environment.
  • Plan to log output with a retention or rotation policy, use absolute paths, and prevent overlapping runs. These are operational safeguards, not YouTube requirements.

Choose one-play or repeat playback

Playback mode FFmpeg behavior Choose it when
One play Use the input once; omit -stream_loop -1. The event should end when the file finishes.
Repeat continuously Use -stream_loop -1 before the input it applies to. FFmpeg documents this as infinite looping. You intentionally want the prerecorded file to repeat until you stop the encoder or end the event.

Looping does not make a broadcast self-ending. If you use it for a scheduled event, arrange a deliberate stop so the stream does not continue beyond the intended window.

Match FFmpeg output to YouTube’s ingest settings

YouTube recommends RTMPS, the secure extension of RTMP. Its published encoder guidance includes H.264, H.265/HEVC, and AV1 options depending on configuration; frame rates up to 60 fps; CBR bitrate encoding; AAC or MP3 audio; and a recommended 2-second keyframe interval, with 4 seconds as the maximum. Choose the bitrate for the actual output resolution and frame rate from YouTube’s current settings rather than copying a value for a different format. See YouTube’s encoder settings, bitrates, and resolutions.

FFmpeg’s -re input option reads media at its native frame rate (equivalent to -readrate 1), rather than consuming a file as fast as possible. Place input options before the input they affect. In FFmpeg documentation, -stream_loop -1 means infinite input looping. Verify option behavior against the documentation for your installed release. FFmpeg’s command-line documentation describes these options.

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

Stream-copy or transcode?

  • Stream-copy: Copy the existing audio and video streams when their codecs, timestamps, frame rate, and container are acceptable to the ingest workflow. This avoids re-encoding, but it does not fix an incompatible source.

  • Transcode: Encode to an output format and settings that fit the source and YouTube’s current recommendations. This allows changes to codec, resolution, frame rate, or audio, but requires CPU capacity. Choose and validate output options for the installed FFmpeg build and available VPS resources.

    Rank #3
    Mini PC Stick Fanless, Micro Desktop Computer Win 10 Celeron J3455, 4GB RAM 64GB eMMC, Gigabit Ethernet, 4K@60Hz Output, WiFi BT 5.0 for Industrial IOT, Business, Office & Digital Signage
    • 【Fanless Design for Uninterrupted Stability】Perfect for noise-sensitive environments and 24/7 operation. This mini PC delivers completely silent performance with an efficient cooling system that prevents overheating. It reliably runs office software and HD video without slowdowns, making it ideal for focused offices, home theaters, and demanding industrial IoT applications
    • 【Ultra-Portable & Ready for Any Screen】Extremely compact and lightweight, this is a full Windows 10/Ubuntu computer that fits in your pocket. It's the ultimate plug-and-play solution for business presentations on a projector, digital signage in classrooms, or entertainment on your home TV. Achieve true "work from anywhere" flexibility with one device for all scenarios
    • 【Stunning UHD 600 Graphics】Experience vibrant, fluid visuals with 4K @ 60Hz output. Powered by Intel UHD 600 Graphics, this mini PC is your perfect home entertainment center for streaming movies, attending online classes, or hosting video conferences. It turns any display into a sharp, high-definition visual experience
    • 【Versatile Ports for Easy Expansion】Tackle multiple tasks with ease using our comprehensive selection of ports. Connect storage, keyboards, monitors, and more simultaneously with 2x USB 3.0 ports, a Gigabit LAN port, and a TF card reader. With convenient USB-C charging, it becomes the effortless control center for your office or home setup
    • 【Pre-Installed & Ready to Go】Get started immediately with the genuine Windows 10 Pro operating system pre-installed. Paired with 4GB LPDDR4 RAM and 64GB eMMC storage, it's fully equipped for everyday office tasks and HD content right out of the box. This hassle-free setup is perfect for businesses, schools, and users who want a simple, ready-to-run computer

Do not assume one command works for every file or FFmpeg build. The following is a command shape, not a tested turnkey script. Replace the placeholders with the exact event values, select suitable output options, and keep the real key out of shared logs and shell history:

ffmpeg -nostdin -re -i /absolute/path/video.mp4 [output and encoding options] -f flv 'rtmps://INGEST_URL/STREAM_KEY'

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

For intentional infinite looping, add -stream_loop -1 before -i. For a one-shot event, leave it out. The output container and encoding options must suit the source and YouTube ingest settings; confirm that the URL and path format match the values shown in Studio. FFmpeg recommends disabling console input checks for background tasks; -nostdin helps avoid an unattended process waiting for terminal input.

Put the command in a script and schedule it

Use a wrapper script

A wrapper script makes it easier to set a working directory, refer to protected configuration, and write logs than placing a long command and secret directly in a crontab. For example, create a script at an absolute path such as /opt/youtube-live/start-stream.sh, make it executable, and have it invoke the selected FFmpeg command. Adapt the paths and permissions to your Linux distribution and service account. Do not include the actual stream key in the script if it will be readable by other users.

Test the script manually as the same account that cron will use. Check that the media opens, FFmpeg connects, output reaches the event preview, and the process exits or continues as intended. Capture standard output and errors in a log location with restricted access and a retention plan; avoid logging credentials.

Add a cron entry for the planned start

Edit the crontab for the account that should run the script, for example with crontab -e, then add a schedule using the absolute script path. A five-field entry has the general shape:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Glorlin Mini PC - Ryzen 5 3501U (up to 3.7GHz), 16GB DDR4 512GB SSD, Mini Desktop Computer with Triple 4K Display Support, WiFi 6 Bluetooth 5.3, Small Micro PC for Work, Study & Multitasking
  • 【Smooth Performance for Daily Work】Powered by Ryzen 5 3501U(4 cores, 8 threads, up to 3.7GHz), this mini PC handles everyday tasks smoothly. It works well as a small computer for office work, browsing, and multitasking.
  • 【16GB Memory for Better Responsiveness】With 16GB DDR4 RAM and a 512GB SSD, this mini computer runs multiple apps and tabs more smoothly. A reliable small PC for users who need consistent performance.
  • 【Expand Your Workspace Easily】Supports up to three displays through HDMI and USB-C connections. This mini desktop computer setup helps improve workflow when working across multiple screens.
  • 【Flexible Connectivity Options】Includes WiFi 6, Bluetooth 5.3, USB ports, Ethernet, and audio connections. This micro PC integrates easily into different desktop computer setups.
  • 【Compact Alternative to Larger Systems】Compared with traditional desktop computers, this small PC saves space while providing the functions needed for daily computing. Suitable for users considering mini computers.

MINUTE HOUR DAY-OF-MONTH MONTH DAY-OF-WEEK /absolute/path/start-stream.sh

Replace the fields with the intended schedule, and consult the cron implementation and operating-system documentation for the VPS: scheduling syntax and environment details are not guaranteed to be identical everywhere. Cron normally provides a smaller environment than an interactive shell, so set needed paths and working directories explicitly in the script rather than relying on your login environment. Keep secrets out of the cron line. Confirm the configured timezone and server clock so the job runs at the intended local or event time.

A cron schedule launches work; it is not a process supervisor. Avoid duplicate jobs and overlapping runs. If you need ongoing process supervision or failure recovery, consider a separate service-management approach and configure it so it cannot restart a stream after its planned end.

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

Verify the broadcast in YouTube Studio

  1. Before the real event, use a private or unlisted test event. Check video, audio, aspect ratio, and the encoder preview.

  2. At the scheduled time, confirm the cron job ran and inspect the FFmpeg log for connection or input errors.

  3. In Live Control Room, wait for the preview. For the documented scheduled encoder flow, select Go live when ready. Do not treat a successful process start as confirmation that the public event is live.

    Best Value
    Getorli Mini PC AMD Ryzen 5 3501U (4C/8T, Max 3.7GHz) Small Desktop Computer 16GB DDR4 RAM 512GB NVMe SSD Budget Micro Compact PCs 4K HD Dual HDMI WiFi 6 BT5.3 Prebuilt OS-Home Office Gaming Streaming
    • 【Great power in a small computer】Get fast performance from the AMD Ryzen 5 3501U ​CPU (2.1GHz-3.7GHz, 4 Cores 8 Threads) inside this mini pc, TDP 15W up to 25W. It's perfect for all your home office​ and business use, like daily computing, web browsing, and smooth media streaming. This small desktop computer​ handles everyday tasks easily and quietly.
    • 【Work on many things at once with lots of storage】This mini PC comes with 16GB of fast DDR4 RAM (expandable up to 32GB), allowing you to smoothly run multiple programs, dozens of browser tabs, and large files all at once. It also features a spacious 512GB NVMe SSD that provides ample storage and delivers dramatically faster boot-ups, app launches, and file transfers compared to a traditional hard drive.
    • 【See everything clearly on one or two 4K screens】Connect one or two monitors for more space to work or play. Dual HDMI ports​ on this mini pc​ support super sharp 4K Ultra HD​ video. It's great for doubling your work area for business​ or watching movies in high definition.
    • 【Fast modern connections in a tiny box】Enjoy a better and more stable internet connection with the latest WiFi 6. Use Bluetooth 5.3​ to connect wireless headphones, keyboards, and mice without wires. This small pc​ is very compact​ to save desk space and has extra USB ports (USB 2.0×2, USB 3.0×2, Type-c 2.0×1, Type-c 3.2 full featured×1, HDMI×2) for your printer, webcam, or other computer accessories.
    • 【Reliable Warranty and Support】We provides 1 year warranty for each Mini computers. So you don't need to worry about any product problems. If you have any questions about the product, please contact our customer service, we will provide 24-hour professional technical support and serve you at any time.
  4. After the event, stop the encoder or end the broadcast as intended, then inspect Studio for the finished stream and replay. YouTube says streams under 12 hours are automatically archived; do not assume the same automatic archive outcome for broadcasts lasting 12 hours or longer.

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

Troubleshooting common failures

Symptom Likely cause What to check
FFmpeg is running, but viewers cannot watch the event The encoder feed has started, but the scheduled event has not been taken live in Studio. Open Live Control Room, wait for the preview, and follow the event’s Go live step.
No preview appears Wrong ingest URL or key, network/protocol issue, or FFmpeg input/output failure. Compare the endpoint and key with the event’s Studio settings; inspect FFmpeg errors and confirm RTMPS support and outbound connectivity.
The job works manually but not from cron Cron’s working directory or environment differs from your shell. Use absolute paths, set the working directory and required environment explicitly, run as the intended account, and capture logs.
Video or audio is rejected or plays incorrectly The source streams or output settings do not match the ingest requirements, or timestamps/container details are unsuitable. Inspect the source codecs and streams, compare output with YouTube’s current encoder guidance, and test a transcode if stream-copying is unsuitable.
The VPS becomes overloaded Transcoding or a high-resolution/high-bitrate source exceeds available CPU or network capacity. Check process and egress use; reduce the encoding workload or choose a VPS capacity that fits the actual media and output requirements.
The stream starts again after it should have ended A loop option or automatic restart policy continues sending media after the intended window. Remove -stream_loop -1 for one-shot playback and review any supervisor or retry behavior; stop the process deliberately.

Or let it run in the cloud

If you do not want to maintain a VPS, cron schedule, and FFmpeg process, StreamNeo keeps uploaded videos playing as a YouTube livestream from the cloud. Upload a recording or build a playlist, add your YouTube stream key once, and go live. Nothing has to stay on at home; it streams the video as uploaded at any quality up to 4K 60fps for one flat price per slot, with automatic recovery if YouTube drops the stream. The first day is free with no card. Monthly pricing is $9.99 per month. StreamNeo is for YouTube streams from uploaded videos, not camera broadcasts. Start the free day with StreamNeo.

Frequently Asked Questions

Does cron automatically click Go live in YouTube Studio?

No. In the documented scheduled encoder workflow, start the encoder, wait for its preview in Live Control Room, then click Go live. API-based automation is a separate implementation.

Can I stream the same prerecorded file continuously?

Yes. FFmpeg’s -stream_loop -1 option loops the input indefinitely; omit it when the event should end with the file.

How long can I leave a YouTube livestream running and still expect an automatic archive?

YouTube says streams under 12 hours are automatically archived. Its cited guidance does not establish the same automatic archive outcome for longer streams.

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

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.

CronFFmpegLinux VPSlivestreamingYouTube Live

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.