Find the answer to your Linux question:
Results 1 to 4 of 4
Hi guys, just a quick question on cronjobs. Code: * */24 * * * '/script.sh' will run every 24 hours, correct? if say for example, the computer was not used ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2009
    Posts
    53

    cronjob.


    Hi guys, just a quick question on cronjobs.

    Code:
    * */24 * * * '/script.sh'
    will run every 24 hours, correct?

    if say for example, the computer was not used for 36 hours, would this script run as soon as that user was logged on?


    Thanks.

  2. #2
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    629
    Quote Originally Posted by NiGhtMarEs0nWax View Post
    Hi guys, just a quick question on cronjobs.

    Code:
    * */24 * * * '/script.sh'
    will run every 24 hours, correct?

    if say for example, the computer was not used for 36 hours, would this script run as soon as that user was logged on?


    Thanks.
    Code:
     10 1 * * * /script.sh
    would run at 01:10 AM every day.
    Code:
     0 0 * * * /script.sh
    would run at midnight every day.
    Code:
     0 0 * * 1-5 /script.sh
    would run at midnight monday through friday.

    The use of "/" is for having multiple times such as I want the script to run on even hours
    Code:
     0 0/2 * * * /script.sh
    Which is sort cut over:
    Code:
    0 0,2,4,6,8,10,12,14,16,18,20,22 * * * /script.sh

  3. #3
    Just Joined!
    Join Date
    Dec 2009
    Posts
    53
    * 1/2 * * *

    wouldn't this run every odd hour from 1am?



    going by that logic then

    0 0/24 * * *

    would run every 24 hours? isn't it the same as

    * */24 * * * ??




    what i am looking for is a script to run every 24 hours regardless of what time it is.
    the reason being, i have no idea when the user will be logged on, but i wish to run the script when they are, only once per day.


    thanks.

  4. #4
    Linux Guru
    Join Date
    Oct 2007
    Location
    Tucson AZ
    Posts
    3,190
    cron counts from zero so minutes can be: 00 -59, hours 00-23. Try changing your 24 to a 23. Just google cron tutorial and see examples.

    Cron Tutorial

    CRONTAB Tutorial | LinuxWebLog.com

Posting Permissions

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