LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-04-2012, 10:33 PM   #1
jasperux
LQ Newbie
 
Registered: Jul 2012
Posts: 1

Rep: Reputation: Disabled
Script not working in cron but working fine manually


Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered.

The script is as follow:

#!/bin/sh

for file in file_1.txt file_2.txt file_3.txt
do
awk '{ print "0" }' $file > tmp.tmp
mv tmp.tmp $file
done


And the cron job I am making is:

*/2 * * * * /root/folder/test.sh

Thanks for the help.
Edit/Delete Message
 
Old 07-04-2012, 11:10 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
You need to give the full path to the files you're trying to read/write to
 
Old 07-04-2012, 11:28 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
... and likely the cmds like awk as well.
Note also that if cron has an issue, it should email the job owner and/or root, so try mailx as each user.
See also /var/log/cron, /var/log/messages
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
script not working with cron mahendra singh Linux - Newbie 7 06-11-2012 01:10 PM
My script is working fine but when it is re-execute then problem start. dhirendrs Programming 2 08-04-2010 05:02 AM
Variable in script not working in cron Aslan_Eident Linux - Server 6 01-02-2009 05:04 PM
PHP script through cron not working fine. vikasumit Linux - General 5 09-04-2008 02:22 PM
Command not working in cron job, but works fine in root Roosta21 Linux - Software 4 11-22-2007 08:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration