LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-14-2012, 05:10 PM   #1
fusion1275
Member
 
Registered: Jul 2007
Location: Portsmouth, Hants
Distribution: Linux Mint
Posts: 266

Rep: Reputation: 35
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
 
Old 04-14-2012, 06:06 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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.
 
Old 04-14-2012, 06:54 PM   #3
fusion1275
Member
 
Registered: Jul 2007
Location: Portsmouth, Hants
Distribution: Linux Mint
Posts: 266

Original Poster
Rep: Reputation: 35
Of course!! Thank you.

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

Thanks for your help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Vixie-Cron not running /etc/cron.d/ dman777 Linux - Software 1 02-09-2011 08:42 AM
vixie-cron fails with System error Mathieu Linux - Software 9 08-30-2006 03:18 PM
vixie-cron update wanted Ystack Linux - Software 2 01-12-2006 10:24 PM
Problem with using vixie cron sendas4 Linux - Newbie 2 07-05-2005 06:38 PM
vixie-cron issues Bigun Linux - Software 1 12-17-2004 10:08 AM


All times are GMT -5. The time now is 07:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration