linux - Crontab running a script in UNIX -


have simple script run top comman nand store result in txt file.it run loop 3 times day 1 hour gap.once done email sent using text file content body of email , delete text file next day new text file.

problem

  1. to automate process have create cronjob start @ 8.30 pm,which start script , script keep runing 4 hours , result of command appeneded in text file , sent on mail.cron >> 0 10 * * * /tmp/ssh-abc/kkk/report.sh

    /tmp/ssh-abc/kkk/report.sh: line 34: reportprod.txt: permission denied

code

for generating txt file

{ //some logic } >> reportprod.txt   //running script manually works great , generate txt!! 

delete file after mailing.

find /tmp/ssh-abc/kkk/*.txt -type f -delete   //this works fine manually,file getting generated , deleted also. 

/tmp/ssh-abc/kkk/report.sh: line 39: reportprod.txt: no such file or directory

can me out problem here? have goggled few things not hitting right point. given permission folder 0755 in expectation cron execute without problem. tried giving cd , path , command in crontab seems not working

  • is possible give permission crontab able access code , owner,no 1 else.

note : not added #!/bin/bash , "whereis sh" gives me sh: /bin/sh /usr/share/man/man1/sh.1.gz /usr/share/man/man1p/sh.1p.gz

in script, make sure cd directory want output file reportprod.txt created in. script attempt create in current directory have different value when cron runs it.
running script /tmp/ssh-abc/kkk/report.sh doesn't mean working directory /tmp/ssh-abc/kkk.

alternately, supply full path want output file go to. example:

{ # output generated here } >> /full/path/to/output/reportprod.txt 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -