[NTLUG:Discuss] How to get mv to not report when there are no files?

Preston Hagar prestonh at gmail.com
Tue Nov 6 16:37:21 CST 2007


On Nov 6, 2007 9:44 AM, Neil Aggarwal <neil at jammconsulting.com> wrote:
> Hello:
>
> I have a cron job with this command:
> mv /home/johnc/* /var/www/html/incoming
>
> If there is a file in the /home/johnc directory, I get
> no output, but when the directory is empty, I get this
> notification to the root email account:
>
> mv: cannot stat `/home/johnc/*': No such file or directory
>
> This job runs every 5 minutes so this is annoying.
>
> Is there a way to supress that output?
>
> Thanks,
>         Neil
>
> --
> Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
> Eliminate junk email and reclaim your inbox.
> Visit http://www.spammilter.com for details.
>
>
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss
>

The redirecting output to /dev/null as suggested by Fred is the best
idea I can think of as well.  I was wondering though if there might be
a better way to accomplish what you are trying to do.  There may be a
specific reason you have a cron script mv everything every 5 minutes
and if so, please disregard this, but as a potential helpful tidbit,
would symlinks work in this situation?

You could remove your johnc folder (rmdir /home/johnc after you had mv
everything out) and then run the command:
ln -s /var/www/html/incoming/ /home/johnc

Then everything dropped into your /home/johnc directory would already
be in your /var/www/html/incoming directory.  It wouldn't need a cron
job to move it over.  Anyway, just a thought in case you hadn't run
across symlinks before.

Preston



More information about the Discuss mailing list