Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Tutorials»[SOLVED] Cron job wget writing files to root directory

    [SOLVED] Cron job wget writing files to root directory

    By RahulJune 2, 20211 Min Read

    The wget command is a command line utility for downloading files from the remote servers. It’s also used to triggers server side scripts using the cron jobs.

    Advertisement

    Problem

    While using the wget with cron job saved the downloaded files under home directory. Due to this a large number of junk files get created in your system.

    Solution

    Use -O option with wget command to write the result file (data) to specific file and location. Next select /dev/null device file as target file. This will discard anything written to it. In result, no junk files will be created in your home directory.

    For example, the original cron job command is:

    wget https://www.example.com/cron.php
    

    Update above command to:

     wget -q -O /dev/null https://www.example.com/cron.php
    

    Here:

    • -q Turn off wget command output
    • -O /dev/null Write downloaded content (file) to /dev/null device.

    That’s it. Hope this tutorial helps you to avoid unwanted files on root generated by wget cron jobs.

    cron cronjobs wget
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Understanding 2>&1 in Bash: A Beginner’s Guide

    How to Choose the Best Shebang (#!) for Your Shell Scripts

    Modulus Operator (%) in Bash

    Using Modulus Operator (%) in Bash

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Implementing a Linux Server Security Audit: Best Practices and Tools
    • cp Command in Linux (Copy Files Like a Pro)
    • 15 Practical Examples of dd Command in Linux
    • dd Command in Linux (Syntax, Options and Use Cases)
    • Iptables: Common Firewall Rules and Commands
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.