I am trying to set up CRON jobs on cPanel v. 76.0.18 and I get "no input file specified" (NIFS), and looked into other posts (e.g., NIFS1, NIFS 2, NIFS 3, NIFS 4), not sure how to solve it.
My samples of CRON jobs:
*/10 * * * * /usr/bin/php -q /home/dir/dir/cron_dir/file-1.php
0 * * * * /usr/bin/php -q /home/dir/dir/cron_dir/file-2.php
* * * * * /usr/bin/php -q /home/dir/dir/cron_dir/file-3.php
0 * * * * rm -rf /home/dir/dir/data_dir_1
0 0,6 * * * rm -rf /home/dir/dir/data_dir_2
0 0,4 * * * rm -rf /home/dir/dir/data_dir_3
How do I solve "no input file specified" error?
Thanks a million guys!
If the command executes correctly in CLI directly, you might try putting it in a .bash file and referencing that in cron. I've seen weird issues with commands in cron, and sometimes wrapping it in a script can help.
If it /doesn't/ execute correctly in CLI, then you might start there :p
Related
here my problem width crontab:
I need to run a php script everyday at noon and so on my crontab i set:
# 0 0 * * * /usr/bin/php -c /var/www/fanta-trade/operazioni_pianificate_medaglie.php > /var/www/cron_log
0 12 * * * root /usr/bin/php /var/www/offertegaseluce/operazioni_pianificate.php > /var/www/offertegaseluce/cron_log
*/15 * * * * /usr/bin/php -q /var/www/fanta-trade/operazioni_pianificate_ordini.php > /var/www/cron_log
#20 */6 * * * /root/certs/certbot-auto renew --quiet --no-self-upgrade
the line that i need is actually the second... i tried many debugging:
I checked the timezone and it is properly set to europe-rome
I checked width whereis the position of php and /usr/bin/php is correct
I tryed to run the script as root or just widthout user specification
0 12 * * * /usr/bin/php /var/www/offertegaseluce/operazioni_pianificate.php > /var/www/offertegaseluce/cron_log
I checked if crontab as a sevice is running and restarted it
I checked if the script itself is reacheable and if it works and if i call the script via browser it works
but actually crontab is not executing the script it just copy paste the cript itself to the log file
any suggestion?
thanks
I have to export products in the .csv or .txt file automatically all the time for the price compare feeds.
First, I was able to export products only via URL like this:
https://site-name.com/Process/Cron.php?run=1&engine=ExportProducts&service=1&profile_id=90&export_file=testcron_export.csv
But, I needed to export the products automatically on some time interval and for that I found a way to run the URL for exports of products in .csv or .txt file from terminal with the following command:
REQUEST_URI=‘Process/Cron.php’ SCRIPT_NAME=‘Process/Cron.php’ php-cgi -f Process/Cron.php run=1 engine=ExportProducts service=1 id=90 export_file=testcron_export.csv
And the products were exported successfully.
But, when I am setting up this command in the crontab, it’s not executed.
I tried using different ways, one of the ways is:
Copied the command (from above) in bash script and executed it successfully from terminal, but when I set-up the bash script in the crontab it's not executed.
These are all the combinations that I’ve tried in the crontab:
*/2 * * * * REQUEST_URI=‘Process/Cron.php’ SCRIPT_NAME=‘Process/Cron.php’ php-cgi -f Process/Cron.php run=1 engine=ExportProducts service=1 id=90 export_file=testcron_export.csv
*/2 * * * * ./testcron2.sh
*/2 * * * * ~/www.site_name.com/testcron2.sh
*/2 * * * * sh /home/site_name/SspStore/testcron2.sh
*/2 * * * * sh testcron2.sh
*/2 * * * * /bin/sh testcron2.sh
*/2 * * * * /bin/sh /home/site_name/SspStore/testcron2.sh
*/2 * * * * php-cgi -f REQUEST_URI=‘Process/CoreCron.php’ SCRIPT_NAME=‘Process/Cron.php’ Process/Cron.php run=1 engine=ExportProducts service=1 id=90 export_file=testcron_export.csv
*/2 * * * * usr/bin/sh testcron2.sh
*/2 * * * * usr/bin/sh /home/site_name/SspStore/testcron2.sh
PS. The shell script (testcron2.sh) is in the home directory of the shop.
Maybe the problem is with php-cgi that cannot be executed from terminal or I am missing something?
Thank you very much in advance
When i run my url https://localhost/panel/index.php?m=user_games&p=check_expire by using chrome the code is run and shutting down the server when expier.
But when i need to run this as a crontab using this command:
* * * * * * wget -q --spider "https://localhost/panel/index.php?m=user_games&p=check_expire"
nothing happend, why?
Seem the crontab not run, because you define wrong crontab command. You put six *, as I know we just need five *. Please try like this
* * * * * wget -q --spider "https://localhost/panel/index.php?m=user_games&p=check_expire"
To make sure your crontab run, please create log when wget executed.
I created a file name 'testCrontab.php' in /var/www/html folder on amazon ec2, ubuntu-based,
$output = shell_exec('crontab -l');
var_dump($output);
The problem is when I invoked this file in browser it shows
string(207) "0 0,6,12,18 * * * /usr/bin/php /var/www/html/testExec.php 0 3 * * * /usr/bin/php /var/www/html/testCrawlback.php 0 4 * * * /usr/bin/php /var/www/html/testInsertCard.php * * * * * NEW_CRON * * * * * NEW_CRON "
Which I guessed those NEW_CRON are from the other time I tested inserting a new cron from php,
but when I invoked this file from command line by issuing /usr/bin/php /var/www/html/testCrontab.php it shows
string(169) "0 0,6,12,18 * * * /usr/bin/php /var/www/html/testExec.php
0 3 * * * /usr/bin/php /var/www/html/testCrawlback.php
0 4 * * * /usr/bin/php /var/www/html/testInsertCard.php"
Also, command crontab -l result in the latter output.
Please help enlighten me what happen here.
Result will be different because when you are executing script via browser the user will be www-data or nobody. It will show the crons of that user. If you execute the script from command line it will show the crons of that particular user.
Edit
Set cron for webuser
sudo crontab -u webuser -e
List crons of webuser
sudo crontab -u webuser -l
webuser will be nobody or www-data or apache
You can find it by executing the following code from web browser.
<?php $output = exec('whoami');
echo $output;
?>
I have a file in mysite.com/url1/url2/cronjob.php which has to be run every minute. I try every combination, but can't succeed. What should I run in command line? Thank you.
In case you'd set it up in a crontab, this works:
*/1 * * * * /usr/bin/wget -O /dev/null http://example.com/cron.php
Steps your shell
$ crontab -e
* * * * * php -f /path/to/cron.php
~
~
I got confused for the first time where to add all of these and finally found.
Type the following in the linux/ubuntu terminal
crontab -e
select an editor (sometime it asks for the editor) and this to run for every minute
* * * * * /usr/bin/php path/to/cron.php &> /dev/null
The PHP interpreter.
/[path-to-php]/php -f [your-php-script]
Are you looking for help to make an UNIX cronjob?
If so, have you tried to edit /etc/crontab, and add
\1 * * * * user command
where user is either root or your name. Im not exactly sure how to access and URL, but a dirty way could involve downloading the link as a file, e.g. "wget http://url.com/page.php"