Script gives error when scheduled in crontab

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Script gives error when scheduled in crontab
# 1  
Old 05-30-2017
Script gives error when scheduled in crontab

i have written one script which is working fine when i run it manually but giving error when i schedule it in crontab.
cat SUMMARY.sh
Code:
 
 #!/bin/bash
 DT1=`date +%Y%m%d`
echo "Off      PP          TT" >>summary_$DT1.txt
 
cat ues1.txt_$DT1 >>summary_$DT1.txt
cat ues2.txt_$DT1 >>summary_$DT1.txt
cat ues3.txt_$DT1 >>summary_$DT1.txt
cat ues4.txt_$DT1 >>summary_$DT1.txt
cat ues5.txt_$DT1 >>summary_$DT1.txt
cat ues6.txt_$DT1 >>summary_$DT1.txt

error getting while running from crontab
Code:
 
 cat: ues1.txt_20170530: No such file or directory
cat: ues2.txt_20170530: No such file or directory
cat: ues3.txt_20170530: No such file or directory
cat: ues4.txt_20170530: No such file or directory
cat: ues5.txt_20170530: No such file or directory
cat: ues6.txt_20170530: No such file or directory

# 2  
Old 05-30-2017
There is no path to your file, cron is the most dumb program you will find.. it has a very minimalist environment so all has to be given...
# 3  
Old 05-30-2017
You need to cd to where the files are.
Also cat means concatenation, so you can do the same in one stroke
Code:
#!/bin/bash
if cd /path/to/the/files
then
  DT1=`date +%Y%m%d`
  echo "Off      PP          TT" >>summary_$DT1.txt
  cat ues{1,2,3,4,5,6}.txt_$DT1 >>summary_$DT1.txt
fi


Last edited by MadeInGermany; 05-30-2017 at 10:37 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Script when scheduled in Crontab gives extra records in output

Hi, We have created a script that's checks the latency of IIDR subscription by fetching details from a config file (that contains subscription details) and running the CHCCLP command. The out put is then concatenated in a csv file. Once all subscription details are saved the script send a mail... (7 Replies)
Discussion started by: ab095
7 Replies

2. Shell Programming and Scripting

Log file is not updating when I run shell scripts scheduled thru crontab

Hi Forum, Good Day! I have created an empty html file wtih permissoin 777 created shell script(with permission 777) , code is below. #=======================start============== . /data09/oracle/apps_st/appl/D_oraapp095.env rm -rf /home/mnp/Test_log.txt echo... (1 Reply)
Discussion started by: kartheekbk
1 Replies

3. Shell Programming and Scripting

Scheduled job not running automatically in crontab

i have a job scheduled in crontab. The problem is, it is not running automatically as per the time scheduled. But runs when executed manually. What would be the problem? Help me with this please. (6 Replies)
Discussion started by: Santhosh CJ
6 Replies

4. Red Hat

Script not working if crontab scheduled

Hi all, I'm working to a script with /bin/bash shebang. The script works perfectly if I run from command line. The script runs under a non root user and inside the commands are set with sudo command in a such a way they can be run under root, for example (first rows of the script):... (5 Replies)
Discussion started by: idro
5 Replies

5. UNIX for Dummies Questions & Answers

crontab scheduled details required

Hi, I have the below job scheduled in crontab. Can you please tell me at what interval this job is scheduled? Where is the name of the job defined here? I will definitely go through the UNIX documentation a little later, for the time being, please provide me few details on this. Thank you. ... (0 Replies)
Discussion started by: Dev_Dev
0 Replies

6. Shell Programming and Scripting

A running Script giving error while scheduled in cronjob

Hi, I have script which is properly running but when i schedule it in cron it throws an error like : Your "cron" job on retrprdapp1 /usr/bin/sh /retr/cron/ftp.sh 2>&1 produced the following output: /retr/cron/ftp.sh: syntax error at line 17: `(' unexpected line17 is # Get list of... (10 Replies)
Discussion started by: rajagasti
10 Replies

7. UNIX for Dummies Questions & Answers

Getting error when running script through crontab

Hi all, I wrote small script for Solaris and when I am running it through command prompt its ok, but when I trying to run it using crontab, i am getting error like: ld.so.1: dbloader: fatal: libACE.so: open failed: No such file or directory /tmp/file.sh: line 5: 8304 Killed ... (4 Replies)
Discussion started by: nypreH
4 Replies

8. UNIX for Advanced & Expert Users

ftp script scheduled in autosys

I am trying to schedule FTP script through autosys.The scripts works perfectly fine in unix environment.All the run time parameters are evaluated in the profile.Both are unix servers. But the strange thing is that the script is not getting executed through autosys and it returns success and... (1 Reply)
Discussion started by: dr46014
1 Replies

9. Shell Programming and Scripting

Problem with executing a script scheduled in crontab

Hi I have written a shell script(in Solaris) in which following logic is there..... i=1 while read control do key=`echo $control | awk -F$DELIMITOR '{ print $1 }'` echo "Key Values" ${key} i=`/usr/bin/expr $i + 1` done < $CONFPATH/$CONFFILE when i execute it at prompt it... (4 Replies)
Discussion started by: Amardeep
4 Replies
Login or Register to Ask a Question