Find the answer to your Linux question:
Results 1 to 5 of 5
hi all i'v got this entry in my crontab file * * * * * /bin/date >/tmp/date.out 2>&1 can anyone tell me what this means? thank you...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2007
    Posts
    16

    Cron file


    hi all

    i'v got this entry in my crontab file

    * * * * * /bin/date >/tmp/date.out 2>&1


    can anyone tell me what this means?


    thank you

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,167
    Quote Originally Posted by alexsqlforums View Post
    * * * * * /bin/date >/tmp/date.out 2>&1


    can anyone tell me what this means?
    What it does is to output the date into a temporary file. The asterisks mean "any time" so presumably it runs every time cron wakes up (which I think is once a minute). The 2>&1 bit means error messages go in the file too. But what it's for I can't imagine.
    "I'm just a little old lady; don't try to dazzle me with jargon!"

  3. #3
    Just Joined!
    Join Date
    Oct 2007
    Posts
    16
    thank you

    i will remove it

  4. #4
    Just Joined! jdh239's Avatar
    Join Date
    Sep 2006
    Posts
    55
    #--------------------SYNTAX--------------------#
    # min(0-59) hour(0-23) dayOfMonth(1-31) month(1-12) dayOfWeek(0-6) (sun=0)
    #
    # Every 5 minutes, for example, can be stated as follows:
    # 0-55/5 OR 0,5,10,15,20, and so on
    #
    # From 8 am to 5 pm can be specified as 8-17 or 8,9,10,11, and so on
    #
    #------------------END SYNTAX------------------#


    Above is the syntax used for cron files. I place this at the tops of my crontabs to remind me of the syntax.

    Here are some examples

    #The following executes at 1:01 AM every day
    01 01 * * * /var/qmail/bin/update_tmprsadh > /dev/null 2>&1
    # The following executes every hour (ie: 1:00, 2:00)
    00 * * * * /root/.SCRIPTS/GREYLISTING/greylisting-delete-expired.sh
    # The following executes at 1:05 AM every day
    05 01 * * * updatedb
    # The following executes at 1:01 AM every day. NOTE: 01 and 1 are the same. Both work.
    1 1 * * * vnstat -u
    # The following executes at the bottom of each hour, at 3 AM, on the 1st, 5th, 9th, 14th, 18th, 23rd, 28th of each month, no matter what day it is.
    0 3 1,5,9,14,18,23,28 * * /root/AUTOMATION_SCRIPTS/BACKUP/7backups
    #* * * * * /root/AUTOMATION_SCRIPTS/JOHN/server

    #-------------------PERSONAL-------------------#
    # The following line executes at the bottom of each hour, every 2 hours between 8 am and 4 pm, M-F
    00 8-16/2 * * 1,2,3,4,5 /root/.SCRIPTS/PERSONAL/drink_water

    #-------------------WEBSITES-------------------#
    # The following line executes every 5 minutes, every day of the week and month
    0-59/5 * * * * /srv/www/htdocs/mydomain.com/contact/format.sh
    # The following line executes every 10 minutes
    0-55/10 * * * * /srv/www/htdocs/mydomain.com/news/script/news.sh

    NOTE: Fields are space delimited. Comma delimited within each respective field. If you want something to execute at 1:01 and 1:05, the syntax is as follows:
    CORRECT: 1,5 1 * * * * <command>
    INCORRECT: 1, 5 1 * * * * <command>


    2>&1 is typically used in this scenario
    <some command> > /dev/null 2>&1

    Basically, you execute the command, but don't get any output on the screen. You can see I use this in my cron above.

  5. #5
    Just Joined!
    Join Date
    Oct 2007
    Posts
    16
    jdh239 thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •