简体   繁体   English

Cron 作业 Linux Shell 命令 SiteGround - 它在哪个目录中运行?

[英]Cron job Linux Shell command SiteGround - What Directory does it run in?

New to Siteground hosting, Cron jobs and Linux. Siteground 托管、Cron 作业和 Linux 的新手。

I have a directory where I want to remove files older than 30 days on my WordPress website.我有一个目录,我想在我的 WordPress 网站上删除超过 30 天的文件。

The Linux shell command is Linux shell 命令是

find path/to/files/* -mtime +30 -exec rm {} \;

The question is about the path to use.问题是关于使用的路径。 I don't know where this Cron job is running from.我不知道这个 Cron 作业是从哪里运行的。

If I create a cron job with just如果我只创建一个 cron 作业

find *

The log file produces the following results...日志文件产生以下结果...

tmp
tmp/somefile1
tmp/somefile2
etc...

Where is tmp? tmp在哪里? And what should I use in my path for my command to get to where I want it.我应该在我的路径中使用什么来让我的命令到达我想要的地方。

If I FTP to my site using FileZilla, this is the path to my directory in question...如果我使用 FileZilla FTP 到我的网站,这是我有问题的目录的路径......

/mydomain.com/public_html/sr

So, if I edit my Cron job to execute the following command...因此,如果我编辑我的 Cron 作业以执行以下命令...

find /mydomain.com/public_html/sr/*

I get我明白了

find: '/mydomain.com/public_html/sr/*': No such file or directory

So, just not sure how to specify the path for my Cron job so that it operates on the desired directory.所以,只是不确定如何为我的 Cron 作业指定路径,以便它在所需的目录上运行。

Found the answer after much searching.经过大量搜索找到了答案。

/home/customer/www/yourdomain.com/public_html/sr

Hope this helps others.希望这对其他人有帮助。 The support was no help at all.支持根本没有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM