Executing commands in Crontab

Posted on 2004-10-22
Last Modified: 2010-04-06

In my crontab, when executing the comand below, due to a great number of msg files in lixo directory, it returns a too many arguments error message:

/bin/cp /var/spool/mail/lixo/msg.* /var/spool/mail/lixo/vespera/

I was told there's a way using find / print0 / xargs, but I don't know how to code it. Can anyone help me?


Question by:multisites
    LVL 10

    Expert Comment

    This may be better to post in

    I would say it would be better to make a bash script to do all the running around and copying things, and place a single instruction in crontab to execute that script.

    LVL 18

    Accepted Solution

    Try this:

    ls /var/spool/mail/lixo/msg.* | sed -e 's/$/ \/var\/spool\/mail\/lixo\/vespera\//' | xargs /bin/cp

    (you might like to replace the cp with echo in that command to do some testing with it, that's what I did to write it)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Cisco Complete Network Certification Training

    If you’re an IT engineer or technician, it's time you take your career to the next level. This elite training bundle is brimming with all of the information you need to learn to sit for Cisco CNNA, CCNP, and CCENT certification exams.

    Article by: Matthew
    I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
    It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    857 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now