Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Executing commands in Crontab

Posted on 2004-10-22
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 10

Expert Comment

ID: 12393196
This may be better to post in http://www.experts-exchange.com/Operating_Systems/Linux/Linux_Administration/

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

arantius earned 150 total points
ID: 12396219
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)

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
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 count occurrences of each item in an array.

609 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