Advertisement: Linux VPS for $4/month - based on OpenVZ, credit card accepted, automatic setup.
+ Post New Thread
Results 1 to 2 of 2

Thread: Why cronjob from /etc/cron.monthly/weekly/daily/hourly do NOT run?

  1. #1
    Administrator Fli's Avatar
    Join Date
    Mar 2013
    Posts
    2,422
    Post Thanks / Like
    Blog Entries
    1

    Why cronjob from /etc/cron.monthly/weekly/daily/hourly do NOT run?



    What can be causes that script in /etc/cron.monthly/weekly/daily/hourly folder does not do its job/not executed/not run?

    I think this may help:

    check that script has right permission (-rw------- root root)

    # stat /path/to/script

    now change to proper permission for Linux cron

    chmod 600 /path/to/script

    check that there is new line at the end of script

    command on the last line
    # this is the end
    check that cron service is running (pid exist)

    # pgrep cron

    try to add this line to the beginning of the script:

    #!/bin/sh

    try to use full pathes for commands in the script

    like not "find parametershere", but "/usr/bin/find parametershere" to discover full path, do example. "which find" command or "which grep" etc.

    check that user that should run the script is defined

    if the script is launched from an file in /etc/cron.d/ directory, then try to add "root" into the file, ie.:
    0 */1 * * * root /usr/sbin/tmpwatch -am 1 /tmp/nginx_client

  2. #2
    Junior Member imort's Avatar
    Join Date
    Apr 2016
    Posts
    15
    Post Thanks / Like


    Is this useful / helpfull? Yes | No
    I can also add a few tips and tricks here:

    1. Try add output redirecting to the end of the line to some log file, it can help you to investigate cron jobs issues in future.
    You can do it like that:

    #!/bin/sh
    echo date > /var/logs/myjob.log
    rsync -a -R /folder1/ /folder2 >> /var/logs/myjob.log

    You'll see any rsync output here

    2. Check any directory paths for running commands too
    For example, if you run 'rsync ./ /folder2' you'll need to add 'cd /folder1' before that to script work!

    You also can take a look to the my cron jobs article here.

+ Post New Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
 Protected by : ZB BLOCK  &  StopForumSpam