LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 03-11-2008, 12:24 AM   #1
manoj.linux
Member
 
Registered: Aug 2007
Posts: 284

Rep: Reputation: 17
cronjob problem


Hi,

I am not getting output of ls command Ihave schdule cron job,I have used following command for user test, I want every 2 min ls command should be executed.

02 * * * * /usr/bin/ls > /home/test/ls.txt
 
Old 03-11-2008, 01:42 AM   #2
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
Code:
*/2 * * * * /usr/bin/ls > /home/test/ls.txt
 
Old 03-11-2008, 03:28 AM   #3
manoj.linux
Member
 
Registered: Aug 2007
Posts: 284

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by Berhanie View Post
Code:
*/2 * * * * /usr/bin/ls > /home/test/ls.txt
Thanks but still the file ls.txt is not creating, can u give me some idea
 
Old 03-11-2008, 03:30 AM   #4
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Why don't you try something like

Code:
*/2 * * * * /usr/bin/ls /home > /home/test/ls.txt
 
Old 03-11-2008, 03:35 AM   #5
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Actually, does /usr/bin/ls exist or is it an inate system command?

Code:
*/2 * * * * ls /home > /home/ls.txt
works for me, whereas the version I posted previously produces a zero length file
 
Old 03-11-2008, 09:39 AM   #6
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
Quote:
Thanks but still the file ls.txt is not creating
It may be because the cron process didn't have permission to create the file (e.g. /home/test/ doesn't exist, or has the wrong permissions). Only the logs will tell you for sure. Check /var/log/cron and read your email for any messages from cron.

Last edited by Berhanie; 03-11-2008 at 09:41 AM.
 
Old 03-11-2008, 11:40 PM   #7
manoj.linux
Member
 
Registered: Aug 2007
Posts: 284

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by Berhanie View Post
It may be because the cron process didn't have permission to create the file (e.g. /home/test/ doesn't exist, or has the wrong permissions). Only the logs will tell you for sure. Check /var/log/cron and read your email for any messages from cron.
Thanks Berhanie, I have done the necessary changes,Now file is creating.
 
Old 03-17-2008, 11:52 AM   #8
sixty_nine
LQ Newbie
 
Registered: Mar 2008
Posts: 5

Rep: Reputation: 0
for non-working cron job always watch the log file.
The default log file for cron job is /var/log/cron
 
  


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
Cronjob problem. Unknown Command dragunu Linux - Newbie 1 05-16-2006 12:47 PM
Problem with cronjob Arndt Linux - Newbie 1 04-05-2005 05:40 AM
cronjob problem chadi Linux - General 5 10-10-2004 09:09 PM
cronjob problem ashley75 Linux - General 2 05-28-2004 05:47 PM
Su in a cronjob michedlp Programming 3 11-06-2003 08:30 AM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 06:02 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