1

I have below entries in crontab -e ,

0 16 * * * /opt/nginxstack/Dropbox-Uploader/DatabaseDumper.sh > /var/log/cron.log 2>&1
19 20 * * * /opt/nginxstack/Dropbox-Uploader/upload_dump_dropbox.sh > var/log/cron.log 2>&1

The first shell script works fine while the second doesn't get executed. I could not find anything in the log as well. can someone please help. Permissions are set correctly and /opt/nginxstack/Dropbox-Uploader/upload_dump_dropbox.sh works when run from terminal.I am running as root.

Edit: below is the code i have in upload_dump_dropbox.sh

#!/bin/bash
/opt/nginxstack/Dropbox-Uploader/dropbox_uploader.sh upload /opt/nginxstack/Dropbox-Uploader/mysqldumpsvps/* /mysqlbckfromvps
4
  • 2
    Both cron entries clobber (overwrite anew) the /var/log/cron.log file; are you perhaps only seeing the 4pm results, and not looking between 8:19pm and 4pm? I'd recommend appending the logs or using different log files.
    – Jeff Schaller
    Jun 24, 2018 at 17:43
  • I tried this now and do not see the log file itself.9 20 * * * /opt/nginxstack/Dropbox-Uploader/upload_dump_dropbox.sh > var/log/cron2.log 2>&1
    – Anand G
    Jun 24, 2018 at 17:49
  • Well, with the crontab entry in your comment, don't you need to wait til 20:09 (in whatever timezone you are in)?
    – nohillside
    Jun 24, 2018 at 18:01
  • 1
    The second cro job has a redirection to a relative pathname. There might be a typo (missing / before var). That would cause the script to not execute at all, unlee that path existed in the working directory.
    – Kusalananda
    Jun 24, 2018 at 18:17

1 Answer 1

2

When a redirection fails on the command line, the associated command is not executed.

Example:

$ echo 'hello' >nonexistent/path
/bin/sh: cannot create nonexistent/path: No such file or directory

(echo never gets to execute)

Your second cron job redirects to a relative pathname, var/log/cron.log. If that pathname is not available from the working directory of the job, this redirection will fail and the job will not execute at all.

The cron daemon should have sent the owner of the crontab an email with the error message for each execution attempt.

2
  • Can u please look at this question my gedit command not working either on crontab -e stackoverflow.com/questions/72711625/…
    – user786
    Jun 22, 2022 at 9:23
  • 1
    @user786 Sorry, I don't really answer questions on demand, or on SO. But your issue is with the graphical user interface and the fact that the environment that cron is executing your command from is not tied in any way to the desktop environment that may or may not be running. Look for questions here about using cron to start graphical applications. Also, it makes no sense (to me) why you would want to start an editor on a schedule.
    – Kusalananda
    Jun 22, 2022 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.