Visit Our UNIX and Linux User Community


cron job problem with csh script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cron job problem with csh script
# 1  
Old 04-11-2002
Question cron job problem with csh script

I've written a csh shell script to number each line of a file.
Firstly, the program count the number of the file and create a file with number at the front. Then, combine the file together.
when i call the program manually, it works.However, when i set it in the cronjob, the output always leaves 3 numeric blank lines.
Is there somthing wrong for my program deal with cron job?
Thanks for your help.

#combine.x
#!/bin/csh

set ofname=tempa
set oftmp=$1
set oname=$1.txt

@ count=`more $oftmp | wc -l`
@ ll=1

while ( $ll <= $count )
echo $ll"." >> $ofname
@ ll++
end

set formfile="paste -d "\|" $ofname $oftmp"

$formfile > testing.$oname
rm $ofname $oftm



Manually call output: ( $HOME/combine.x abc.log )

1.|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
.......
49.|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
50.|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Cron job Output ( 0,15,30,45 * * * * $HOME/combine.x abc.log > /dev/null 2>&1 )
1.|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
.......
49.|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
50.|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
51.|
52.|
53.|

Last edited by fung_donald; 04-11-2002 at 06:45 AM..
# 2  
Old 04-11-2002
Could not get your script to work exactly correct, but did note that the only way I would get extra output is if there were extra lines in the original file - if I put an extra blank line in the first file, then I would get an extra line in the final file. Three extra blank lines, three extra lines in the final file.

Check your data in the original file. There may be either three returns in it or something else causing your problem.
thehoghunter
# 3  
Old 04-11-2002
Opps, forgot you said "in cron" it added the lines.

Change the line
@ count=`more $oftmp | wc -l`

to

@ count=`cat $oftmp | wc -l`
thehoghunter
# 4  
Old 04-11-2002
Ar, it works.

Thanks, thehoghunter.

Previous Thread | Next Thread
Test Your Knowledge in Computers #807
Difficulty: Medium
A key advantage of a MOSFET is that it requires zero input current to control the load current.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execution problem with CRON job

HI, I have written an executable file in unix and I was able to execute it successfully but when I called this file with cron job it was giving error like "permission denied" and "No such file or directory". Please help in how cron calls the file and what permission is required on the file... (2 Replies)
Discussion started by: vipin kumar rai
2 Replies

2. Solaris

Problem with a cron job

When i am trying to open crontab throught command crontab -e. It is not opening? OUTPUT: # crontab -e sh: vim: not found The crontab file was not changed. Please let me know how to open and edit it??? (10 Replies)
Discussion started by: kkalyan
10 Replies

3. UNIX for Dummies Questions & Answers

Cron job problem

I have a perl script which Im planning to run every minute. I have set the cron job as * * * * * PATH= /usr/local/bin:/usr/bin:/usr/sbin:/usr/lib; perl /dm2/www/html/isos/pre5.3/autoDownload.pl I assume the script is executing every minute only because I see a entry like below when I do... (2 Replies)
Discussion started by: srijith
2 Replies

4. UNIX for Dummies Questions & Answers

EOF problem with Cron Job?

Hey guys... first post here... I have set up the following cron to create daily backups for me and rotate them weekly: date=`date +%d`; tar -zcvf /home/mysite/backups/backup_dev_$date.tgz /home/mysite/public_html/dev/app --exclude=/home/mysite/public_html/dev/app/tmp However, I keep... (4 Replies)
Discussion started by: Crazy Serb
4 Replies

5. Shell Programming and Scripting

Cron job running problem

Hi Guys, I am trying to run a script through contab. The script can only be executed once user logs in as su - oracle. I have tested the script other then cronjob and it executes successfully, more over the paths used in the script are absolute paths. Crontab entries are as as below.... (3 Replies)
Discussion started by: Asteroid
3 Replies

6. Shell Programming and Scripting

Problem with Cron job

Hi , I have a TCL script which i am supposed to run as a cron job.. The script works fine from command line , but when run as a cron job , its unable to find a package,, my crontab is as follows. --------------------------- #!/usr/bin/ksh * * * * * PATH=/cm8/auto/Automation/Library/TclLib ... (7 Replies)
Discussion started by: Sudharshana
7 Replies

7. UNIX for Dummies Questions & Answers

Problem running a cron job

I have created a cron job for the vtiger workflow to execute the shell file named com_vtiger_workflow.sh to run the workflow. I've created the following line in crotab -e : 00 13 * * * /var/www/html/prashant/cron/modules/com_vtiger_workflow/com_vtiger_tiger_workflow.sh | mail -s 'Check... (2 Replies)
Discussion started by: anaigini45
2 Replies

8. Solaris

problem with cron job

new to unix here, im learning how to schedule jobs with crontab. The following cron job runs under root but not under a test account i created. 50 11 * * 0 /usr/bin/banner "HELLO" > /dev/console i have no idea with it isn't running under the test account but runs right on time when i create... (7 Replies)
Discussion started by: solne
7 Replies

9. Solaris

cron job problem

I am trying to setup cronjob and once I start to save it is not working. This is what I am getting after I executed crontab -e, I am not even getting the privious entry and I am running from root. crontab -e 421 10 3 * * * /usr/sbin/logadm ? :wq ? Why is it not saving? Any input is... (4 Replies)
Discussion started by: mokkan
4 Replies

10. UNIX for Dummies Questions & Answers

problem when the script is scheduled to run as cron job

Hello, I have problem in executing a shell script. When the shell script is executed at the shell prompt the script works successfully but when the same script is run as a cron job it fails to execute the files called within the shell script. I have scheduled the job in my crontab file as ... (6 Replies)
Discussion started by: forumthreads
6 Replies

Featured Tech Videos