LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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
Senior Member
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 2,731

Rep: Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975Reputation: 975
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
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,261

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
... 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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


All times are GMT -5. The time now is 01:06 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration