Why csh script was made a mistake with Crontab in Ubuntu Linux?
Dear Friends
I have csh script file as bellow: #!/bin/csh -f 1/ When I run this script standalone by using command like this: csh scriptfile The result was export correctly. 2/ Now I want to run this script every 6 hours in crontab of Ubuntu Linux 10.04. Unfortunately, it was made a mistake. In crontab, I was set some parameters as bellow: crontab -e 01 5-23/6 * * * csh /path/scriptfile Please help me. Thanks a lot! |
What is the error message you see when it runs from cron? You may need to explicitly set the PATH in your script for it to run correctly from cron.
|
Specify:
• Operating system, because way of crontab entries creation may be different in different OS. • Any error message? • Output of: Code:
~$ which csh Code:
~$ crontab -e |
If the script is marked as executable you can drop the "csh" part and just use /path/to/script
|
Quote:
It can be removed only if user's default shell and shebang (script interpreter) are same, then the script can be executed as: Code:
~$ ./script.sh Code:
~$ csh ./script.sh |
RE: Crontab in Ubuntu linux 10.04
Hi, Buddies
I tried to use with all your solution, but it's still not work correctly. 1/ When I run with csh scriptfile the result was exported like this STATUS: 20130129-1419 (UTC: 2013 01 29 - 0619): Getting igu17252_06.sp3 wait 3 hrs The file "igu17252_06.sp3" is exactly file that I want to download. You can refer to website: ftp://cddis.gsfc.nasa.gov/gps/products/1725/ (User: anonymous Pw: your email address) to get for more detail information. 2/ Regarding to crontab in Ubuntu Linux, actually it is NOT show any error message when running. However, the result is NOT showed correctly with the same method 1 (csh scriptfile). STATUS: 20130129-1419 (UTC: 2013 01 29 - 0619) : Getting igu00063_-03.sp3 wait 3 hrs As you can see two files are different name although it was run at the same time (UTC: 2013 01 29 - 0619). Only file name was show on method 1 (running script file standalone) correctly, and file name "igu00063_-03.sp3" was wrong. That's why my script can not download the file from website when I use crontab. Please help me. |
Quote:
When a script file is marked executable, the first line is used to identify the interpreter, and any flags/parameters that may be required. The only time the users shell is used is when that first line does not have that specification. If the file starts with "#!" but no other specification then the users shell is used. According to the the first post, the script has "#!/bin/csh -f" which should work just fine without having to use the csh explicitly. |
Can you post the full output of your script when run from cron and command line? It would also help to add an echo after you set each variable for debugging (echo $wd, etc.), so you can see the actual value the variable is getting.
|
Ok, I've get it working by changing crontab like:
# m h dom mon dow command SHELL=/bin/csh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/abc 15 5-23/6 * * * csh /opt/abc/scriptfile restart Thanks you for help |
All times are GMT -5. The time now is 04:49 PM. |