Linux Cron Job

Posted on 2009-02-17
Last Modified: 2013-12-15
I need to issue this command every minute from within /etc/crontab:
echo 3 > /proc/sys/vm/drop_caches

What is the line I need to add to /etc/crontab to make it work?

 * * * * root echo 3 > /proc/sys/vm/drop_caches DOES NOT WORK

and a number of other variants...

true expert needed on this one...
Question by:lvnv
    LVL 48

    Accepted Solution

    How are you determining it isn't working?
    LVL 4

    Assisted Solution

    0,1,2,3  *  *  *  *  script
    */1  *  *  *  *  script

    The format */1 is not supported on all platforms.

    The * in the filed means all possible values for that field. Thus for the minutes field it will cover the whole range 0-59.
    LVL 48

    Expert Comment


    * * * *

    is the correct/valid format for all Linux/Unix systems.
    LVL 40

    Assisted Solution

    why do you want to create the file in /proc/sys/vm ? I don't think you can create files there ! try to send it to /tmp or some other dir
    LVL 12

    Assisted Solution

    ok.. try adding /bin/echo in front first.. if that dosent work then create a script like this :

    /bin/echo 3 > > /proc/sys/vm/drop_caches

    then add it to your cron script

    0-59 * * * * /<location of script>/<scriptname>.sh

    that will make it run every minute..

    LVL 40

    Expert Comment

    I tried to copy / create files under that dir on fedora 8 and it says that I can not create regular file

    Author Closing Comment

    umm...I'm giving you all 125 points to keep quiet...
    it was my own fault...Late night dumb error...
    crond was stopped...
    turned it on and all is good...
    thanks for your replies

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
    I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now