I installed froxlor a while back and uninstalled it again, because it didn't fit my need. the server I'm running is a debian web server. after inspecting the system log file using
grep CRON /var/log/syslog
I noticed that there are still some froxlor things going on.
most noticable are log entries like:
Jun 25 10:55:01 v220200220072109810 CRON[5633]: (root) CMD (/usr/bin/nice -n 5 /usr/bin/php -q /var/www/froxlor/scripts/froxlor_master_cronjob.php --tasks 1> /dev/null)
Jun 25 11:00:01 v220200220072109810 CRON[5727]: (root) CMD (/usr/bin/nice -n 5 /usr/bin/php -q /var/www/froxlor/scripts/froxlor_master_cronjob.php --tasks 1> /dev/null)
however, when inspecting the crontab for the root user, I don't have any active crontabs. Any ideas on how to fix this issue?
Related
I'm trying to run some cron jobs as root but it seems that my crontab it's not working. After reading a lot of threads here in SO I've changed these things:
I've removed the sudos inside the crontab.
I've added the full path of all the commands inside the crontab.
I've restarted the cron job each time I've changed it.
But it's not working yet.
This is my current crontab (I call it from my sudo user with "sudo crontab -e" to run it as root):
0 4 * * * /usr/bin/find /var/backups/mongobackups/ -mtime +7 -exec rm -rf {} \; > /var/log/log1.log
5 4 * * * /usr/bin/mongodump --out /var/backups/mongobackups/`date +"%m-%d-%y"` --ssl --sslPEMKeyFile=/etc/ssl/mongo.pem --username <mymongoadminusername> --password <mymongoadminpassword> --authenticationDatabase=admin > /var/log/log2.log
30 4 * * * /opt/letsencrypt/certbot-auto renew > /var/log/log3.log
35 4 * * * /etc/init.d/nginx reload > /var/log/log4.log
40 4 * * * /bin/cat /etc/letsencrypt/archive/<mydomanin>/{fullchain1.pem,privkey1.pem} | /usr/bin/tee /etc/ssl/mongo.pem > /var/log/log5.log
What I'm trying to do with these 5 commands is:
At 04:00. Remove all backups that are more than 7 days old.
At 04:04. Backup all my mongodb databases.
At 04:30. Try to renew my SSL certificate.
At 04:35. Reload Nginx service.
At 04:40. Update my mongodb.pem file with the new certificate.
It's important to say that each of these commands running from the shell one by one with sudo are working properly.
But from the cron the results are:
I don't know if this command is working. The log file (log1.log) is empty.
It's not working. No backup have been created. The log file (log2.log) has not been created.
It seems that it's working. The log file (log3.log) shows the standard output when you run this command correctly.
It seems that it's working. The log file (log4.log) shows the standard output when you run this command correctly.
It seems that it's not working. The mongo.pem file has the correct updated date but the file is empty. The files fullchain1.pem and privkey1.pem have the correct content, so it seems a problem with "/usr/bin/tee /etc/ssl/mongo.pem". The log file (log5.log) has not been created.
Finally the cron.log shows this:
Nov 11 04:00:01 myservername CRON[31286]: (root) CMD (/usr/bin/find /var/backups/mongobackups/ -mtime +7 -exec rm -rf {} \; > /var/log/log1.log)
Nov 11 04:05:01 myservername CRON[31297]: (root) CMD (/usr/bin/mongodump --out /var/backups/mongobackups/`date +")
Nov 11 04:05:01 myservername CRON[31296]: (CRON) info (No MTA installed, discarding output)
Nov 11 04:07:01 myservername CRON[31306]: (root) CMD ( test -x /etc/cron.daily/popularity-contest && /etc/cron.daily/popularity-contest --crond)
Nov 11 04:17:01 myservername CRON[31325]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Nov 11 04:30:01 myservername CRON[31353]: (root) CMD (/opt/letsencrypt/certbot-auto renew > /var/log/log3.log)
Nov 11 04:30:04 myservername CRON[31352]: (CRON) info (No MTA installed, discarding output)
Nov 11 04:35:01 myservername CRON[31393]: (root) CMD (/etc/init.d/nginx reload > /var/log/log4.log)
Nov 11 04:40:01 myservername CRON[31420]: (root) CMD (/bin/cat /etc/letsencrypt/archive/<mydomanin>/{fullchain1.pem,privkey1.pem} | /usr/bin/tee /etc/ssl/mongo.pem > /var/log/log5.log)
Nov 11 04:40:01 myservername CRON[31419]: (CRON) info (No MTA installed, discarding output)
If I'm not wrong the error "No MTA installed, discarding output" is not a problem because it's related to sending the output by email, am I right?
So anyone could tell me what is wrong with my crontab?
Thank you very much!
I don't know what is the problem with my crontab but this is working if I put all these commands inside a script and call this script inside the crontab.
The script (myscript.sh):
#!/bin/bash
/usr/bin/find /var/backups/mongobackups/ -mtime +7 -exec rm -rf {} \; > /var/log/log1.log
/usr/bin/mongodump --out /var/backups/mongobackups/`date +"%m-%d-%y"` --ssl --sslPEMKeyFile=/etc/ssl/mongo.pem --username <mymongoadminusername> --password <mymongoadminpassword> --authenticationDatabase=admin > /var/log/log2.log
/opt/letsencrypt/certbot-auto renew > /var/log/log3.log
/etc/init.d/nginx reload > /var/log/log4.log
/bin/cat /etc/letsencrypt/archive/<mydomanin>/{fullchain1.pem,privkey1.pem} | /usr/bin/tee /etc/ssl/mongo.pem > /var/log/log5.log
The crontab:
00 03 * * * <pathtomyscript>/myscript.sh
This is working now.
I have a node.js server app which is being started twice for some reason. I have a cronjob that runs every minute, checking for a node main.js process and if not found, starting it. The cron looks like this:
* * * * * ~/startmain.sh >> startmain.log 2>&1
And the startmain.sh file looks like this:
if ps -ef | grep -v grep | grep "node main.js" > /dev/null
then
echo "`date` Server is running."
else
echo "`date` Server is not running! Starting..."
sudo node main.js > main.log
fi
The log file storing the output of startmain.js shows this:
Fri Aug 8 19:22:00 UTC 2014 Server is running.
Fri Aug 8 19:23:00 UTC 2014 Server is running.
Fri Aug 8 19:24:00 UTC 2014 Server is not running! Starting...
Fri Aug 8 19:25:00 UTC 2014 Server is running.
Fri Aug 8 19:26:00 UTC 2014 Server is running.
Fri Aug 8 19:27:00 UTC 2014 Server is running.
That is what I expect, but when I look at processes, it seems that two are running. One under sudo and one without. Check out the top two processes:
$ ps -ef | grep node
root 99240 99232 0 19:24:01 ? 0:01 node main.js
root 99232 5664 0 19:24:01 ? 0:00 sudo node main.js
admin 2777 87580 0 19:37:41 pts/1 0:00 grep node
Indeed, when I look at the application logs, I see startup entries happening in duplicate. To kill these processes, I have to use sudo, even for the process that does not start with sudo. When I kill one of these, the other one dies too.
Any idea why I am kicking off two processes?
First, you are starting your node main.js application with sudo in the script startmain.sh. According to sudo man page:
When sudo runs a command, it calls fork(2), sets up the execution environment as described above, and calls the execve system call in the child process. The main sudo process waits until the command has completed, then passes the command's exit status to the security policy's close method and exits.
So, in your case the process with name sudo node main.js is the sudo command itself and the process node main.js is the node.js app. You can easily verify this - run ps auxfw and you will see that the sudo node main.js process is the parent process for node main.js.
Another way to verify this is to run lsof -p [process id] and see that the txt part for the process sudo node main.js states /usr/bin/sudo while the txt part of the process node main.js will display the path to your node binary.
The bottom line is that you should not worry that your node.js app starts twice.
I have a crontab job setup to run every 5 minutes. it runs fine without any issues. But once a while a run fails.
e.g
its run fine at 5th, 10th , 15th minute of an hour but the 20th minute will not run but runs fine again at 25th minute.
next time may be the 55th minute fails. ( random times on random servers)
i checked in /var/log/cron and there are entries for all the executed jobs but for the missed job there is not even an entry.
eg. in the below /var/log/cron job rmlogs ran fine at 21.35 missed running at 21.40 but runs again at 21.45.
Jun 12 21:35:01 [serverxxxx] CROND[4167]: (vfhttpd) CMD (/opt/vmware/vfabric-web-server/http-proxy/tools/rmlogs -t 5 >> /opt/vmware/vfabric-web-server/http-proxy/logs/rmlogs.log 2>&1 #PUPPET)
Jun 12 21:40:01 [serverxxxx] CROND[4201]: (root) CMD (/usr/lib64/sa/sa1 -S DISK -F 1 1)
Jun 12 21:41:02 [serverxxxx] CROND[4213]: (root) CMD (/usr/local/bin/monitor_mcollective >/dev/null 2>&1 #PUPPET)
Jun 12 21:45:01 [serverxxxx] CROND[4225]: (riak) CMD (/opt/riaktools/riak-create-logs -p /var/log/riak > /dev/null 2>&1 #PUPPET)
Jun 12 21:45:01 [serverxxxx] CROND[4227]: (vfhttpd) CMD (/opt/vmware/vfabric-web-server/http-proxy/tools/rmlogs -t 5 >> /opt/vmware/vfabric-web-server/http-proxy/logs/rmlogs.log 2>&1 #PUPPET)
Jun 12 21:50:01 [serverxxxx] CROND[4665]: (root) CMD (/usr/lib64/sa/sa1 -S DISK -F 1 1)
Jun 12 21:50:01 [serverxxxx] CROND[4666]: (vfhttpd) CMD (/opt/vmware/vfabric-web-server/http-proxy/tools/rmlogs -t 5 >> /opt/vmware/vfabric-web-server/http-proxy/logs/rmlogs.log 2>&1 #PUPPET)
Jun 12 21:52:01 [serverxxxx] CROND[4700]: (root) CMD (/usr/local/bin/refresh-mcollective-metadata #PUPPET)
You have a reason to doubt, if your cron job has been started every 5 minutes indeed.
To exclude the doubt you can extend the crontab line, containing your cron job with a prefix:
date >>/tmp/base_name_of_your_cronjob.log;
and check this additional log file.
If this log file contains entries every 5 minutes without a gap, then you should investigate, if /var/cron/log gets a new record for every start of the cron job, including cases, if the cron job crashes.
Additional check point is to make sure that the cron daemon has run permanently and was not restarted. You can do it by checking its process by e.g.
ps -ef|grep crond
I am having an issue getting the .sh file to run. I can run it via sudo ./starter.sh when inside my app directory, but relying for it on reboot isn't working.
I am using an Ubuntu 12.04 VM on Windows 7. I have my files on Windows shared with the VM, so I access my files via /mnt/hgfs/nodejs-test
I am running a node.js server with Nginx via my local VM.
As of right now, I can go to http://node.dev and it will properly load up my server.js located in nodejs-test (/mnt/hgfs/nodejs-test) and output hello world to the screen.
So running the site isn't a problem..but getting forever (forever.js installed globally) to kick in on reboot isn't working. I suspect it simply can't execute my SH file.
Here is my starter.sh
#!/bin/sh
if [ $(ps aux | grep $USER | grep node | grep -v grep | wc -l | tr -s "\n") -eq 0 ]
then
export PATH=/usr/local/bin:$PATH
forever start --sourceDir /mnt/hgfs/nodejs-test/server.js >> /mnt/hgfs/nodejs-test/serverlog.txt 2>&1
fi
Now I have tried sudo crontab -e (and added my path to the file) as well as just crontab -e and did the same thing. Upon reboot...nothing.
#reboot /mnt/hgfs/nodejs-test/starter.sh
I tried editing that cronjob to this
#reboot /var/www/nodejs-test/starter.sh
because I created a symlink in /var/www/nodejs-test to /mnt/hgfs/nodejs-test
Where can I check to see if an error fires on reboot, or is it possible my reboot cron isn't running at all? I know running the starter.sh DOES work though.
EDIT The /mnt/hgfs/nodejs-test is owned by root (which might be a windows thing given the files exist on my Windows 7 os). My ubuntu user is "bkohlmeier" which I created on installing the VM.
EDIT #2
Nov 10 13:05:01 ubuntu cron[799]: (CRON) INFO (pidfile fd = 3)
Nov 10 13:05:01 ubuntu cron[875]: (CRON) STARTUP (fork ok)
Nov 10 13:05:01 ubuntu cron[875]: (CRON) INFO (Running #reboot jobs)
Nov 10 13:05:02 ubuntu CRON[887]: (bkohlmeier) CMD (/mnt/hgfs/nodejs-test/starter.sh)
Nov 10 13:05:02 ubuntu CRON[888]: (root) CMD (/var/www/nodejs-test/starter.sh >/dev/null2>&1)
Nov 10 13:05:02 ubuntu CRON[877]: (CRON) info (No MTA installed, discarding output)
Nov 10 13:05:02 ubuntu CRON[878]: (CRON) info (No MTA installed, discarding output)
Ok, I found a solution. Whether it is the "right" solution I don't know. Because my system shares files between HOST and GUEST (windows 7 and Ubuntu VM), the /mnt/hgfs/ has to get mounted (I think)..and the reboot happens quick enough I think the mount isn't aware yet.
So I added this via crontab -e
#reboot /bin/sleep 15; /var/www/nodejs-test/starter.sh
and it worked like a charm.
I have to migrate a server to a new cloud provider. In doing so I need to copy all the LAMP code to new virtual machine. I did all that. However, on the old server one cron job runs which does something. I'm unable to find the cron file and migrate it to new server. The output of:
grep CRON /var/log/syslog
is
Nov 5 19:00:01 frroleapi CRON[22975]: (root) CMD (php /var/www/api/scheduler.php)
Nov 5 19:05:01 frroleapi CRON[23189]: (root) CMD (php /var/www/api/scheduler3.php)
Nov 5 19:05:01 frroleapi CRON[23190]: (root) CMD (php /var/www/api/scheduler.php)
Nov 5 19:09:01 frroleapi CRON[23382]: (root) CMD ( [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
The last cronjob is a file php5 in /etc/cron.d. However, I'm unable to find the cron files for earlier entries.
You should be able to open the list of scheduled cron events with the crontab command. This should also show you what files run during the cron and where they are located:
crontab -l
You can then add these cron entries to the new server using crontab with the edit parameter, like this:
crontab -e
For more information, see also: http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5
This tutorial may also be helpful for understanding cron and crontab: http://kvz.io/blog/2007/07/29/schedule-tasks-on-linux-using-crontab/