1

I have looked for several reasons that could cause my problem without luck. The issue seems to be extremely particular: my server running LTS 10.04 is not correctly running scripts relating to internet usage. I am trying to update a dynamic dns from my server so that my domain will always point to my server. I ssh to my server to make changes and it's always running.

There are two places I've put the cron script:

1) Add a crontab using crontab -e for the current user

2) Add a file under /etc/cron.d/ (two different files too)

I made sure that they are owned by root and have access bits for the owner.

Ruling out a few things:

1) All cron scripts work perfectly on my laptop which is also 10.04 LTS

2) Both scripts run perfectly fine when run from the command line.

3) On the server if I concat "hello" to a file using cron every minute it actually works

The simpler of the two scripts to be run has configuration like this:

* * * * * root /usr/bin/wget "-q --read-timeout=0.0 --waitretry=5 --tries=10 --background http://freedns.afraid.org/dynamic/update.php?...........

Where I'm hiding the update key and it IS followed by a new line.

I feel like this must be something specific to cron that I'm missing out on.

I also do not have a cron log file in either /var or /var/log

Let me know if there is some information I forgot to mention.

1
  • Wow! I someday started thinking that I was the only one experiencing this kind of issues when it is related to a website's cronjob. I am using Ubuntu 11.04 and experiencing the same as you. I finished using kalarm for my cronjobs, which is doing an awesome work indeed, as I couldn't find enough information about how to fix this and make crontab to work as I wish. I am following your question in order to see if somebody gives a useful answer, anyway all the workarounds are welcome. Thank you! May 9, 2012 at 17:18

1 Answer 1

6
  • Are you aware that cron's error messages / STDERR ends up in the system mail? If you haven't set it up, you can quickly check in /var/mail/your_username. It is called Unix Movemail in Thunderbird, but I believe there are other names for the same mechanism too.
  • Default shell used is sh not bash.
  • Are you aware that the environment for a cron job is entirely different from your interactive shell? To test this I created a cron job:

* * * * * /tmp/testscript.sh

The contents of /tmp/testscript.sh is:

#!/bin/bash
set

I received an email with the following content (notice a.o. things that PATH is very different, compare it with set from the commandline:

BASH=/bin/bash
BASHOPTS=cmdhist:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
BASH_LINENO=([0]="0")
BASH_SOURCE=([0]="/tmp/testscript.sh")
BASH_VERSINFO=([0]="4" [1]="2" [2]="24" [3]="1" [4]="release" [5]="x86_64-pc-linux-gnu")
BASH_VERSION='4.2.24(1)-release'
DIRSTACK=()
EUID=1000
GROUPS=()
HOME=/home/my_username
HOSTNAME=diablo
HOSTTYPE=x86_64
IFS=$' \t\n'
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LOGNAME=jhendrix
MACHTYPE=x86_64-pc-linux-gnu
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/bin:/bin
PPID=623
PS4='+ '
PWD=/home/my_username
SHELL=/bin/sh
SHELLOPTS=braceexpand:hashall:interactive-comments
SHLVL=1
TERM=dumb
UID=1000
_=/bin/bash
1
  • Not quite sure what part fixed it but it seems like adding the bash -c "..." around my command made it work. I also found out how the mail system works which helped me find out which of my cron scripts were failing. Thanks for the quick response =)
    – chrisjleaf
    May 9, 2012 at 19:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .