Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with zip on linux 2

Status
Not open for further replies.

zi8Pxv2R

Technical User
Aug 30, 2012
4
0
0
IN
Hi I'm facing just similar problem as mentioned in this link


i have a sh script which will copy files from other servers and perform the zip of those files.
when i call this script from crontab while performing zip i'm getting some junk file dumped instead of zip file.

-rw-r--r-- 1 root root 1262 Aug 31 01:19 zi8Pxv2R
but when i call this sh script manually the zip is working perfectly.
this is the crontab entry.
*/10 * * * * /staging/cbsinstall/cosmic/crontabTRACE_VOICE.sh
permission for the script is root with 777 and crontab permission is also root
also i have restarted the crond service no luck
let me know if any one has come across this situation and resolved the problem.
 
It's a bad idea to give a root-owned cron job permissions 777; if any user can see the script they can add their own commands to it to make Bad Things happen. 755 is safer.

Can we see the actual contents of the script, it's hard to guess what the problem might be without that.

Also try adding >/tmp/outputfile 2>&1 to the end of the job command line and see if any errors are being logged.

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
hmmm i can explain u this and show you the snippet of script

i do run some commands to collect some information and the files are created on the servers with txt(5 text files on each server,i have 8 servers) format, later files will be transferred to admin server and perform the zip.

once the files are transferred script has got sleep

sleep 5
zip /orvol/cosmic/NAME_`date +%F_Hour%H%M%S`.zip /orvol/cosmic/*.name*.txt
rm -rf /orvol/cosmic/*.name*.txt
 
Can't see anything obviously wrong there, did you try logging the output?

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
Scripts called from crontab usually have a different environment compared to the one you'll have in an interactive shell, especially the PATH-variable may differ. Does your script set up the environment to ensure the correct zip executable is called? Calling executeables with full path (like /usr/local/bin/zip) in scripts run by cron is good practice.
 
Hi Annihilannic
sorry was busy in other stuffs
this is working fine now after adding the >/tmp/outputfile 2>&1 to the job.
Thanks a lot
 
So the errors you captured gave you the solution you were looking for? A star for Anni in that case!

The internet - allowing those who don't know what they're talking about to have their say.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top