LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Having fun with Vixie-cron (https://www.linuxquestions.org/questions/linux-newbie-8/having-fun-with-vixie-cron-939821/)

fusion1275 04-14-2012 04:10 PM

Having fun with Vixie-cron
 
Hi all,

So just installed Vixie-cron on my new Sabayon 8 install and created a nice backup script but it doesnt work. I thought all was well until I wanted to use a double ampersand in between commands in my script. The only part of the script is the second section AFTER the ampersand.

So I have resulted in a cut down simple one liner to test if it really works and still no joy.

Here is the code in script.sh:

Quote:

#!/bin/bash
/bin/echo "Testing123" && /bin/echo "Why wont you work" > /var/log/ScriptOutpu_`date +\%Y\%m\%d`.log
Crontab looks like this:

Quote:

00 18 * * * /usr/local/scripts/script.sh
I am running the script as root so even tried adding the root id in the cron string. Still doesnt work. The only thing that does work is the second part of the script. The part after the double ampersand. Not the "Testing123" part.

Any clues would be great guys.

Thanks

colucix 04-14-2012 05:06 PM

A couple of notes about your test script:
  • the first part before the double ampersand should work, but the output is sent to standard output, whereas the output of the command after && is redirected to a file. In other words the double ampersand separates two different commands, each one with its own redirection. Since the output of the command before && is not redirected to a file, you should have received it in your system mailbox (if a system mail server is running).
  • the full path of echo is not necessary, since echo is a shell built-in - or better - the shell built-in takes precedence over the binary executable. You can see it by means of
    Code:

    type -a echo
  • the escaped % signs are not necessary inside the script. The % sign has a special meaning only when it appears in the crontab entries.
Hope this helps.

fusion1275 04-14-2012 05:54 PM

Of course!! Thank you.

I actually re-read what I created and its obvious now.

Thanks for your help.


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