Cronjob cake not found - cakephp

I'm trying to get my cake shell running on a linux server and having a challenge I know little about handling.
I'm running the following test shell called "cron" to ensure I am on the right cronjob setting:
*/1 * * * * cd /usr/www/users/everest1/ads2/app/app; ../cake/console/cake cron
At first I got "permission denied", which I fixed by updating the file permissions on the cake file. Now I just get this response...
../cake/console/cake: not found
I've even SSH'd to the cake/console directory itself and typed "cake" and still get the same error.
Does anyone have any ideas on how to solve this?
P.S. I'm not use to the SSH world at all or the command line on linux. Today was the first day editing the crontab file which took some reading up on.

Have you put the path of cake in $PATH var?

Ok, I managed to make this come right...
The first step was to read Running Shells as cronjobs
Once that was created I then got an error of "bad interpreter: No such file or directory", which I tracked down to being the first line of the cake shell script which I changed from #!/bin/bash to #!/usr/local/bin/bash
This then meant the file was being processed with the correct bash.
Once that was done, it all worked smoothly.

Related

Redirecting C system() output fails only with yq

I'm using yq to convert a YAML document into JSON for use in a C program. In my program, I convert the file to JSON using the command
system("yq ea \'[.]\' -o=json .cache/BT_nginx-ingress.yaml > .cache/package.json")
However this causes the error:
Error: write /dev/stdout: permission denied
Thoughout my program, I've used redirection several times with the system() command, but it fails in this specific instance.
I can run the command normally from the terminal, without root. I'm using bash on PopOS, so I've also added bash -c to the above system() call, but it fails this way too.
Can anyone help me with this? Thanks!
Edit: More details on my configuration. The current working directory is the same as the program's location which is one directory above .cache. The working directory is never changed. I am the owner of .cache and the files inside. The permissions are r/w for me, and the group. I am running the process but not with sudo. system("echo foo > .cache/package.json") works!
I have managed to fix this issue by adding the yq_linux_amd64 binary with the C program itself, rather than using the yq package from snap. It works fine now, and can redirect outputs without any issue.

Nagios Plugin Error: (No output on stdout) ... failed. errno is 2: No such file or directory

I am using custom Nagios plugins for the first time and am running into this error when I create a service for the plugin.
(No output on stdout) stderr: execvp(/usr/local/nagios/libexec/check_load.py, ...) failed. errno is 2: No such file or directory
The plugin works when I run it on the command line, however does not work when it runs within Nagios.
I followed these steps to get the plugin into Nagios
https://assets.nagios.com/downloads/nagiosxi/docs/Managing-Plugins-in-Nagios-XI.pdf
Here is what it looks like in the Nagios UI
The plugin is in the correct path: /usr/local/nagios/libexec and the resource.cfg file has the same path within it.
I tried two separate plugins, both which work on the command line, and the result is the same error.
The error indicates the file location is incorrect, however the plugin is in the specified directory and runs with no errors within that directory.
I am totally stumped and appreciate any help.
For anyone reading this, I solved the problem.
The first time I added the plugin, I forgot to add the python extension. When I updated the already created plugin, Nagios still threw the error.
Once I completely deleted the plugin and re-created it the 'file not found', error went away.
I faced a similar issue when I was trying to add a custom plugin ( I had custom plugins in ruby and python ).
The issue was the missing shebang line at the start of the script (which determines the script's ability to be executed like a standalone executable).
For example, if you have a python plugin custom-plugin.py then make sure this script has shebang at the start of script #!/usr/bin/env python3. Also if you have other scripts (ruby, bash etc.) make sure to add the appropriate path at the start of your scripts.
Also, check the path for plugins Nagios version. For my setup path was /usr/local/nagios/libexec/ and make sure your custom plugin is executable and has correct ownership permissions.
Sample custom template I used :
define command {
command_name check_switch_health
command_line /usr/local/nagios/libexec/check_snmp.rb --host $HOSTADDRESS$ --model "$ARG1$" --community "$ARG2$"
}
The above workaround worked for me.

Nunit TestResult.xml is not created during Jenkins build

To run tests in Jenkins I use the next batch command:
"C:\Program Files (x86)\NUnit 2.6.4\bin\nunit-console.exe" /result:TestResult.xml "C:\Users\Denis\Documents\Visual Studio 2013\Projects\MyProject\App.nunit"
Here how it looks in Jenkis:
The problem is: it doesn't generate TestResult.xml file!
When I run the same command as a .bat file from my desctop it creates the TestResult.xml file.
Any ideas what is wrong with Jenkins?
P.S. I searched for created file in all possible folders and even via "search"
I came up with thought that the file is generated and removed then or something like this.
The thing is that I don't see this file indeed but Jenkins generated report based on this file! So I think maybe after generating report the file was removed automatically.
I had faced the same issue and I found the test results xml file under my user directory in Win 7.
Note : I think it's some problem with nunit that it doesn't export the file to the location of which we provide the path.

CakePHP 2.0 - Cake was unable to write to File cache

I'm using CakePHP 2.0 RC-1. After checking out the project from SVN, the application is starting to complain that it can't write cache files to the tmp/cache directory. Since this is local, I know the directory is writeable and I can CLEARLY see that the directories are even filled with files, so the error is a bit strange.
Here are some of the errors I've encountered:
_cake_core_ cache was unable to write 'cake_dev_nb' to File cache
fopen(c:\cake\app\tmp\cache\models\cake_model_default_media) [function.fopen]: failed to open stream: No error [CORE\Cake\Cache\Engine\FileEngine.php, line 127]
No error?! Wth?
Now, if I look in the FileEngine file, at line 127 it reads:
if (!$handle = fopen($this->_File->getPathName(), 'c')) {
return false;
}
By replacing the "c" with "w", no error is encountered and everything works as it should. But, it should not be necessary to modify the core Cake libraries to work around this problem. Let me repeat that on my other computer this works as intended, without editing the core library. Both use the Windows OS and the read/write rights to the tmp/cache-folder is exactly the same.
Edit: Here's a site that experiences the error outputs I'm having locally
Example site found by Googling. Not my site: http://www.12h30.net/credit/
Any suggestions?
Update: Here is why: This is caused if you have a PHP-version that's too low, before 5.2.6, as outlined by "api55" in the comments. Thanks for the reply. Hope this helps you too.
Well, in my case, when I checked my app, it hadn't the /tmp folder. Then I created the structure (/tmp/cache/models, /tmp/cache/persistent) and all worked well. This happened to me maybe git ignore empty folders, so they weren't created.
I had a similar problem, it was because I had chown -R www to the app/tmp directory to get Cake to run "properly" without giving everyone write privileges. Looks like during development the only way to use the console and the web is to give everyone write privileges, or add yourself to the www group perhaps.
Easy solution:
chmod -R 777 app/tmp
or
chown -R username app/tmp
while using the console and
chown -R www app/tmp
when using the web
Just give the right CHMOD (776 works fine for me) to app/tmp
for windows users with the same error/warning: make sure you run the command prompt in elevated mode ;)

execute cron with shell using cake php

currently I am using command to execute cron is
cd appfolder.
../cake/console/cake cronname
it is working on local linux server
but,
(1)
/home/chpltv/public_html/cron/cron/cake/console/cake -app "/home/chpltv/public_html/cron/cron/app" news_import_basic >> /home/chpltv/public_html/cron/a.txt
(2) sh ../home/chpltv/boxyourtvtrial.com/cake/console/cake.php -app "/home/chpltv/boxyourtvtrial.com/public_html/cron/cron/app/" news_import_basic >> /home/chpltv/public_html/cron/a.txt
it is not working.
I dont know wht is issue......
Please Help me
please tell me command to run cron in cake php
A shell is run from the app/vendors/shells directory within the application you have created. When you create the shell, if must also follow the same class structure as the other class based code in cake:
class ThisNewNameShell extends Shell {
// functions here
}
Then this shell is called run with the following command:
/path/to/cake/console/cake {name_of_shell} {name_of_function} {args} -app /path/to/app
If you still are not getting the desired results, turn on debugging and run the shell manually to see the output and fix any issues. Once they are resolved, you will have a working cron.
Happy Coding!
Without any error messages, it's hard to diagnose a problem.
Check your email or cron logs (possibly /var/log/cron) for error messages, they may help.
Check the permissions on your files to ensure the cron user can run the cake console etc.
Assuming you have php cli working fine (should be ok if you can run it manually on the same server), is it in the path when the cron executes?
Consider appending 2>/tmp/news_import_basic.err to the cron commands to capture any error messages to a log file.

Resources