Doubt in Crontab


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Doubt in Crontab
# 1  
Old 06-13-2007
Doubt in Crontab

Hi
I am new to this cron jobs in Unix. I gave the following entry to print the date in out_file every minute.
I used crontab -e option.

1 * * * * /usr/bin/date 1>>out_file 2>>&1

But it doesnt seem to be working. No error is also raised. The out_file itself is not created in the HOME directory. I am working in AIX version 5. Is there any environmental variable setting to use this crontab? Any kind of help would be greatful.
# 2  
Old 06-13-2007
Every minute would be all asterisks. Your cronjob is set to run when the minute = 1. That is once an hour at 2:01 3:01 4:01, etc.
# 3  
Old 06-13-2007
See what i get when i try to run the command:
Code:
[root@somewhere1 output]# /usr/bin/date 1>>out_file 2>>&1
-bash: syntax error near unexpected token `&'
[root@somewhere1 output]#

try this instead:
Code:
/usr/bin/date 1>>out_file 2>&1

also make sure that you give correct path of the date command. to know where lies the date command, type:
Code:
whereis date

or
Code:
which date

# 4  
Old 06-13-2007
Perderabo, I tried using all *, then also it is not working. Its the same.
And Yogesh, I tried as u said as well, still it is the same. Well, I gave the path of date command after doing where only. So, the date command path is correct.
# 5  
Old 06-13-2007
Quote:
Originally Posted by charu
Hi
I am new to this cron jobs in Unix. I gave the following entry to print the date in out_file every minute.
I used crontab -e option.

1 * * * * /usr/bin/date 1>>out_file 2>>&1

But it doesnt seem to be working. No error is also raised. The out_file itself is not created in the HOME directory. I am working in AIX version 5. Is there any environmental variable setting to use this crontab? Any kind of help would be greatful.

That will run at 1 minute past the hour. To run every minute:

Code:
* * * * * /usr/bin/date 1>>out_file 2>>&1

# 6  
Old 06-13-2007
Suddenly it seems to be working now...I gave the following entry.
* * * * * /usr/bin/date 1>>out_file 2>&1

However, I would like to know if I can echo it to the screen, like for eg. if I say
* * * * * echo "Hi"
it is not working. I feel its because the cron would be confused as to which tty it has to echo. So, to avoid this problem, what should i do?
# 7  
Old 06-13-2007
Quote:
Originally Posted by charu
Suddenly it seems to be working now...I gave the following entry.
* * * * * /usr/bin/date 1>>out_file 2>&1

However, I would like to know if I can echo it to the screen, like for eg. if I say
* * * * * echo "Hi"
it is not working. I feel its because the cron would be confused as to which tty it has to echo. So, to avoid this problem, what should i do?

What screen?

cron doesn't know anything about any screen, and it is not connected to a terminal.

You can send it to a virtual terminal, e.g., /dev/tty1

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Doubt..

Hi experts, In one of our code we have used some command like this. name=${name##*/} Can someone please let me know what exactly it does? Thanks & Regards, Sathya V. (1 Reply)
Discussion started by: Sathya83aa
1 Replies

2. Red Hat

Doubt

How to create a file with specific size in RHEL6 (1 Reply)
Discussion started by: Sashi Kanth A
1 Replies

3. Ubuntu

Doubt

hi ,, i am new for this.. i want to know abt linux os.. which version is best for it industry.. please suggest me..:cool: (1 Reply)
Discussion started by: c vignesh kumar
1 Replies

4. UNIX for Dummies Questions & Answers

Doubt

Hi , Struck with one basic question. Iam expecting word count of 4 where "wc" is showing as 5 . # echo "abcd" | wc 1 1 5 # echo abcd | wc 1 1 5 (5 Replies)
Discussion started by: penchal_boddu
5 Replies

5. Solaris

doubt regarding crontab entry

Can anyone tell me , in crontab week starts from Monday or Sunday which one mention as 1... Also please let me know what is the use of export term=vt100... (1 Reply)
Discussion started by: rogerben
1 Replies

6. Solaris

doubt reg crontab

Hi, I have a doubt reg crontab entries. If the user name is there in /etc/cron.d/cron.allow and also in cron.deny file will he able to execute. if the user is not in both the file means wt will do? (2 Replies)
Discussion started by: rogerben
2 Replies

7. UNIX for Dummies Questions & Answers

Doubt

How would i create virtual interface in linux to configure more than one IP address for a physical interface? any help wll be appreciated. (1 Reply)
Discussion started by: salil2012
1 Replies

8. Shell Programming and Scripting

Doubt??

I jus want to know the meaning of the below command line(exclamation following that re-direction) sqlplus -s `cat /home/sample.txt` <<! Thanks!! (1 Reply)
Discussion started by: nohup
1 Replies

9. Shell Programming and Scripting

One doubt

Hi, Can i use the shell script like this? When i am running the script it is hanging not giving me any output. I can redirect the output and then i can do the manipulations also but why this one is wrong. I am confused we can do like this or not.. #!/usr/bin/ksh for line in `top` do... (2 Replies)
Discussion started by: namishtiwari
2 Replies
Login or Register to Ask a Question