Hi,

I have added a new entry to the root cronjob to run a shell script. The shell script runs fine on its own. But when I scheduled it to run every minute (for testing if it runs) on the cronjob, it didn't work! I have try many google search and man help, nothing seems to help.

More detail, when I updated the crontab file, it saved and shows my entry via crontab -l. When I save the file, it gives me the message indicating it is saved (vi - ### charaters and stuff), but didn't say my entry is loaded in like it used to (this is on a different machine btw). I have a vague memory that there is a setting whether you want the crontab to reload everytime the file is updated or not. I am wondering, how do you reload it??? Or do I even need to do it?? I am using Solaris.

I am quiet new to this thing. Please help!!

    ...

    runs every minute

    1-59 /myDir/myScript.sh

    Just looks like any other lines that runs....

      Have a look here, it should help.... only joking :p The problem is your first element (0-59) it should be * (every minute). The whole crontab would then read
      every minute of every hour of every day of every month on any day of the week run this.
      NB, you're not redirecting your output anywhere so it will all be mailed back to root. This can get messy if loads of your crontab files are creating loads of output and you never check root's mail file, here at work it 2.5G before anyone noticed that I'd done that. Had about 1500 lines of data being output to stdout every time the script was run (in one form or another it was being run about 80-100 times a day).
      HTH
      Bubble

        You could do what I did: install webmin and let that sort everything out...

          Thanks guys!

          I tried 1 <command line> too, to run every first minute of the hour. Not working. Is there any chance that my entry is not loaded in the to memeory?

          I dont think I have the permission to install anything...

            How did you edit the crontab? Did you edit the crontab file directly or did you use crontab -e ? If the former I think there can be some problems (I've never tried it, I've always payed attention to the warning against it) 😉

            HTH
            Bubble

              When your script runs from crontab, does it either have an evironment (eg a PATH) or have you specified full paths for all your commands (like "/bin/cd" instead of "cd")? I know many systems don't give you any environment except while in a shell so be sure you've checked for that.

              Edit: and unless Solaris is really odd (which it often is), you shouldn't have to "reload" cron or worry about editing the cron file directly.

                I tried crontab < /temp/cronjobs
                where /temp/cronjobs has the updated cronjobs with my entry.
                I have tried crontab -e too
                Both saves the file but only my entry is not running. Others running as usual.
                When I save the cron job file, it should give me a message saying cron jobs has been modified right? Cos I didn't get that msg

                I gave the full path to my shell script, I didn't use any environment variables and I am not allowed to edit any .profiles neither...
                My colleague told me she restarted something when she edited the file. She can't seem to remember what it cos she did it ages ago...

                  Originally posted by illusion
                  Thanks guys!

                  I tried 1 <command line> too, to run every first minute of the hour. Not working. Is there any chance that my entry is not loaded in the to memeory?

                  I dont think I have the permission to install anything...

                  when I have a cron job I want to run every 15 minutes, I'll set it up like this:

                  /15 * /path/to/script

                  also, do a crontab -l, is your new cron job showing up in the list?

                  • keith

                    Yes it does show up in the crontab -l
                    May be I should 2> error.txt on the entry?
                    My shell script is already outputing error tho...that is why I thot it wasn't necessary to put it in the cron job...

                      You could try putting something really simple in the crontab just to check it's running.
                      * echo "Hello" > test_output
                      Bubble

                        3 months later

                        I found the same problem under Solaris 9. To clarify all in advance:
                        The cron is working fine in general, all the scripts have absolute paths. The scripts rune fine from free hand, even if called from outside the working directory. All the file permissions seem OK. My script has output redirected into file (but the cron job itself - hasn't). So I started a war. I wrapped the php script in other shell script-didn't work. I called a php script directly putting #/usr/php as the path to interpreter in the first line of the script - didn't work. I inserted the direct call to php with my script into crontab-didn't work. I recompiled php to add CLI support-didn't work. I wrapped php call in a C program, (spawnle), compiled and ran. By hand-yes, by cron-no. My program ran but the php call was rejected - as if the process couldn't be loaded. I looked in php logs to find out what's wrong and found out that there is no trace of executing my srcipt at all. The cron logs (/var/cron/log AFAIR) show that the job execution failed but give only some error number which I'm unable to decode.
                        What I suspect therefore is that php itself cannot be loaded because the system cannot find the dynamic libraries required to run php. I don't know what is the user who runs cron jobs and if it is root (as in my case) - is the environment (showing the libraries locations (?)) loaded or not. Maybe adding "su - " at the beginning of the script could help? I'm not so tough Solaris guy to answer all this. Next week I'll check this, but maybe somebody will be faster...

                          Note that due to some bad communication under Solaris you cannot edit crontab: neither by crontab -e nor using vi - when you are connecting by ssh (what most of us do). It just rejects your jobs. Use telnet if you can or a terminal console. There is a workaround by setting some sshd variable: you may find it IN THE NET...
                          Cheers

                            there are several different cron daemons out there which have some subtle differences in the crontab syntax and where they expect the crontabs
                            man crond /might/ give you info on which version is installed on your system...also note that '*/15' doesn't work with all of them

                              Write a Reply...