Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have created a Shell Script as below

Sample.sh

  echo "Hi there"

I also added cron job in cron tab which is under /etc/crontab as below

* * * * * /home/Sample.sh > /home/Sample.txt

I have created the Sample.txt file in /home/ directory.

I have also checked the permission for read and write for both the file

When I execute the Sample.sh file it works fine.it writes in Sample.txt file

Now I don't understand why it is not writing in the Text file from the cron task i scheduled

I am using Ubuntu 10.04

Please Help me in fixing this issue

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

You are using the system crontab which has a slightly different format; specifically, the date-time fields must be followed by a user field which tells cron who to run the command that follows as.

So the syntax in this case should be something like:

* * * * * username /home/username/Sample.sh > /home/username/Sample.txt
share|improve this answer
    
Thanks a ton It worked like charm I am sitting on this for past 2 days Thank you so much –  user1093513 Aug 18 '12 at 6:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.