0

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

3
  • Did you check your cron daemon is running? As a side note, your '* * * * *' means you want an execution every minute. Is that what you want? Aug 18, 2012 at 10:33
  • It overwrites the file on each run, are you sure you don't want >> instead?
    – tripleee
    Aug 19, 2012 at 19:24
  • /home is a weird place for your stuff anyway, it would normally be /home/username.
    – tripleee
    Aug 19, 2012 at 19:25

1 Answer 1

0

The first maybe you can script invocation at the top e.g. #!/bin/sh. Its required in file bash.

After you can run as:

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

If you run not okey. You can check stackoverflow.com/11932056#11932056

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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