Crontab not working on Sun Machine

Posted on 2003-03-03
Medium Priority
Last Modified: 2008-03-04
Hi ,
When i execute Commands such as touch and mkdir from crontab ,it runs fine .But when i try to run tcsh scripts from crontab it fails doing nothing .
What might be the problem ????!!!!

Is the current tcsh might be a problem ???

What might be the possible problems and solution ?

Best Regards ,

Question by:sai_pankaj

Expert Comment

ID: 8056740

If you run thoose scripts direclty in another shell than tcsh do, are they working then ?

/Hans - Erik Skyttberg
LVL 21

Accepted Solution

tfewster earned 100 total points
ID: 8057036
cron uses sh to run all commands; Ensure that the scripts have
on the first line.

Plus cron does not use your standard environment, so you may have to specify or source environment variables in your scipt

Finally, cron sends any output and error messages to you as a mail message (unless you've explicitly redirected output to a log or to /dev/null), so check your mail for more details of the problem.

Expert Comment

by:Vinit Kain
ID: 8057079
Before executing from crontab, check these steps :-

1. In your script provide the absolute path of each input and output files
2. Give the execute permission to script
3. Check the read and write permission to all the input and output files.

Vinit Kain
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

LVL 51

Expert Comment

ID: 8057152
if cron fails to execute a command, it mails the result to root
please post error messages (and follow previous hints)
LVL 14

Assisted Solution

chris_calabrese earned 100 total points
ID: 8058021
I'm guessing tfewster is closest to the mark here, but I'm going to go one step further.

Not only does cron use /sbin/sh to execute everything, but it does so in a way that makes it impossible to execute scripts in other languages unless you specify the interpreter in the command-line

So, instead of something like

  04 01 * * * /my/script

You'll need something like

  04 04 * * * /usr/bin/tcsh /my/script
LVL 21

Expert Comment

ID: 8058673
OK, enough guessing...although it's fun trying to work out all the possible problems with cron jobs.

Pankaj, please post the line from your crontab file and an example of the script you are trying to run so we can fix the problem.

Expert Comment

ID: 8090862
Chris posted the correct answer. Cron executes all commands using /sbin/sh. This way it ignores whatever interpreter you specify. So you have to specify /usr/bin/tcsh my-script.

Same goes for rc-scripts, just look at /sbin/rcx. All scripts all executed by /sbin/sh. Nice to know when you're trying to figure out why a ksh startup-script isn't working :-)

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month4 days, 17 hours left to enroll

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question