• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 376
  • Last Modified:

Executing commands in Crontab

Hi:

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?

Thanks.

Mario./
0
multisites
Asked:
multisites
1 Solution
 
frugleCommented:
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.

Mike
0
 
arantiusCommented:
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)
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Tackle projects and never again get stuck behind a technical roadblock.
Join Now