Showing results for 
Search instead for 
Did you mean: 

Cron entry for C script

Frequent Advisor

Cron entry for C script

how to give the crontab entry for the executable script written in C language.
Any answer will be helpful.
Peter Godron
Honored Contributor

Re: Cron entry for C script

its the same format as any other program or script:
0 * * * * /<script>

see "man cron" and "man crontab"

Just be aware that you do not have a "full" environment when you run from cron, so anything like $ORACLE_HOME etc you have to make known to the program !

Please also read:
on how to reward any useful answers given to your questions.

Honored Contributor

Re: Cron entry for C script


the entry would be same as any other script that have scheduled previously.

all you have to ensure is that it is being run under the appropriate environment.


23 15 * * * echo "/home/chetana07/cprog/demo01; exit"|su - oracle 1> /tmp/output_demo01.crn
2> /tmp/error_demo01.crn

# END OF TABLE day0->Sunday day6->Saturday

kind regards
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Volker Borowski
Honored Contributor

Re: Cron entry for C script

May be I get something wrong here...

There is no way to execute a script in C-Language. You need to compile it using a C-Compiler and will receive a binary file that can be scheduled like any other program.

If you are refering to csh-script, the problem is, that cron runs sh. So you need to execute the csh itself and give your script as a parameter like

/usr/bin/csh -c /home/myscripts/thisone.csh

Hope this helps
A. Clay Stephenson
Acclaimed Contributor

Re: Cron entry for C script

Assuming that you have a csh script that will run under cron's sparse environment (ie the script itself sets and exports any needed environment variables -- especially PATH) then all you need to do is to make sure that the very first line of your csh script contains a "shebang" line:

This will cause the script to be run as a csh script regardless of the shell invoked by cron.
If it ain't broke, I can fix that.
Frequent Advisor

Re: Cron entry for C script

Thanks a lot for the response