LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 02-10-2009, 03:48 AM   #1
laki47
Member
 
Registered: Feb 2009
Posts: 33

Rep: Reputation: 15
Crontab - command won't execute


Hello

when I execute following command (bash):

date >report.`date '+%H%M%S'`

I get something like this: report.101215 in current directory (and date inside that file).

And if I exucute that 2 seconds later I'll get report.101217 and also date inside file.

But when I try to edit my crontab file:

* * * * * date >~/path/report.`date '+%H%M%S'`

which should create new file every minute in my $HOME/path directory, the thing doesn't work???

I have no idea why?

Plese help, I'm new to Linux
 
Old 02-10-2009, 03:52 AM   #2
yai
LQ Newbie
 
Registered: Jun 2008
Posts: 19

Rep: Reputation: 1
cron commands will probably be executed without any environment variables set, so no PATH variable. Try a full path name like /bin/date, this might work.
 
Old 02-10-2009, 03:56 AM   #3
laki47
Member
 
Registered: Feb 2009
Posts: 33

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by yai View Post
cron commands will probably be executed without any environment variables set, so no PATH variable. Try a full path name like /bin/date, this might work.
Well, when I try the following:

* * * * * date >>~/path/report.txt

it works perfectly...

but with "dynamic" date/time values in file name it doesn't

I'm very confused

Last edited by laki47; 02-10-2009 at 04:04 AM.
 
Old 02-10-2009, 04:07 AM   #4
kauuttt
Member
 
Registered: Dec 2008
Location: Atlanta, GA, USA
Distribution: Ubuntu
Posts: 135

Rep: Reputation: 26
You can execute crontab if your name appears in the file /usr/lib/cron/cron.allow. If that file does not exist, you can use
crontab if your name does not appear in the file /usr/lib/cron/cron.deny.
If only cron.deny exists and is empty, all users can use crontab. If neither file exists, only the root user can use crontab. The allow/deny files consist of one user name per line.

check 'crontab -l' whether ur job is populated or not in the cron table

-kd
 
Old 02-10-2009, 04:11 AM   #5
laki47
Member
 
Registered: Feb 2009
Posts: 33

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by kauuttt View Post
You can execute crontab if your name appears in the file /usr/lib/cron/cron.allow. If that file does not exist, you can use
crontab if your name does not appear in the file /usr/lib/cron/cron.deny.
If only cron.deny exists and is empty, all users can use crontab. If neither file exists, only the root user can use crontab. The allow/deny files consist of one user name per line.

check 'crontab -l' whether ur job is populated or not in the cron table

-kd
I can use cron, which I mentioned in my second post. Problem is when i try to put time in my file name. Then it won't execute.
 
Old 02-10-2009, 04:57 AM   #6
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
Quote:
* * * * * date >~/path/report.`date '+%H%M%S'`
Remove the ' and that should work. So, it should be like this:

Code:
* * * * * date >~/path/report.`date +%H%M%S`
-twantrd
 
  


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
why won't my crontab execute the commands? dannemil Linux - Newbie 4 02-12-2008 06:25 PM
Script doesn't execute in crontab jis0501 Linux - General 2 08-04-2007 08:09 AM
crontab : why root can't execute ?? bluenectar Linux - General 2 03-12-2007 04:21 AM
crontab execute consecutively SofNine Fedora 17 07-28-2006 02:34 PM
crontab entries will not execute when not logged fatra2 Linux - Software 2 05-23-2006 03:22 AM

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

All times are GMT -5. The time now is 08:27 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration