0

I added the line

*/1 * * * * /home/zach/test.sh

to my crontab, where the contents of /home/zach/test.sh are as follows:

touch /home/zach/test.txt

Yet, no file test.txt is being created in that folder. Is there any reason why cron wouldn't be performing the desired job?

  • Welcome to Ask Ubuntu! In order to answer your question, please provide more information (edit your question). 1) Did you mark the /home/zach/test.sh script executable? (provide the output of ls -l /home/zach/test.sh) 2) Do you have the shebang in the script? (I don't see it in your question) 3) How exactly did you add it to your crontab? (crontab -e?) – gertvdijk Jun 28 '13 at 7:59
1

First, your test.sh file should look like:

#!/bin/bash

touch /home/zach/test.txt

if you want it to be a bash script.

Second, be sure that this script has permissions of executing. To do so, run this command in terminal:

chmod +x /home/zach/test.sh

Third, be sure that you have permission to create new files in /home/zach.

Fourth, add your new cron job using crontab -e command.

0

The /1 is unnecessary. Just do

* * * * * /home/zach/test.sh

EDIT: I wrote "In fact, I think that /N means "skip every N-th instance", and in that case will result in skipping every instance. " This is not true, it means "every N-th instance". Therefore both variants work. Therefore, I will remove my answer. I think you have a permissions problem. Why not try

* * * * * /usr/bin/touch /tmp/blah
0

try * * * * * /usr/bin/sh /home/zach/test.sh

  • January is right, /1 is unnecessary – quidage Jun 28 '13 at 10:32
0

If your script is still not executed, you can refer at http://www.tcpdump.com/kb/os/linux/linux-cron-tutorial.html

  • 2
    Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – gertvdijk Jun 29 '13 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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