0
I’m trying to run a script by crontab of centos, I’m doing so:
crontab -e
then put:
*/1 * * * * root /home/websites/public_html/admin/functions/open.sh
Obs: Before doing this, add permissions to the file
chmod +x open.sh
I’m right, where I’m wrong?
Log presented:
Jul 10 15:31:01 vps CROND[13891]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:32:01 vps CROND[14002]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:32:01 vps CROND[14003]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:33:01 vps CROND[14077]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:33:01 vps CROND[14076]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:34:01 vps CROND[14151]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:34:01 vps CROND[14152]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:35:01 vps CROND[14263]: (root) CMD (/usr/local/cpanel/scripts/dcpumon-wrapper >/dev/null 2>&1)
Jul 10 15:35:01 vps CROND[14266]: (root) CMD (/usr/bin/test -x /usr/local/cpanel/bin/tail-check && /usr/local/cpanel/bin/tail-check)
Jul 10 15:35:01 vps CROND[14265]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:35:01 vps CROND[14269]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:36:02 vps CROND[14404]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:36:02 vps CROND[14405]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:37:01 vps CROND[14596]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:37:01 vps CROND[14597]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:38:01 vps CROND[14647]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:38:01 vps CROND[14648]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:39:01 vps CROND[14720]: (root) CMD (/usr/local/cpanel/scripts/clean_user_php_sessions > /dev/null 2>&1)
Jul 10 15:39:01 vps CROND[14721]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:39:01 vps CROND[14723]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:40:01 vps CROND[14812]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:40:01 vps CROND[14811]: (root) CMD (/usr/local/cpanel/scripts/dcpumon-wrapper >/dev/null 2>&1)
Jul 10 15:40:01 vps CROND[14813]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:41:01 vps CROND[14884]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:41:01 vps CROND[14886]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:42:01 vps CROND[15007]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:42:01 vps CROND[15008]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:43:01 vps CROND[15114]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:43:01 vps CROND[15116]: (root) CMD (/usr/local/cpanel/whostmgr/bin/dnsqueue > /dev/null 2>&1)
Jul 10 15:43:01 vps CROND[15115]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:44:01 vps CROND[15178]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:44:01 vps CROND[15179]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:45:01 vps CROND[15248]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:45:01 vps CROND[15249]: (root) CMD (/usr/local/cpanel/scripts/dcpumon-wrapper >/dev/null 2>&1)
Jul 10 15:45:01 vps CROND[15250]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:46:01 vps CROND[15372]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:46:01 vps CROND[15373]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:47:01 vps CROND[15547]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:47:01 vps CROND[15549]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:48:01 vps CROND[15666]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:48:01 vps CROND[15667]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:49:01 vps CROND[15786]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:49:01 vps CROND[15787]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:50:01 vps CROND[15928]: (root) CMD (/usr/local/cpanel/scripts/dcpumon-wrapper >/dev/null 2>&1)
Jul 10 15:50:01 vps CROND[15930]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:50:01 vps CROND[15931]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:51:01 vps CROND[16090]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:51:01 vps CROND[16091]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:52:01 vps CROND[16295]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:52:01 vps CROND[16296]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:53:01 vps CROND[16454]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:53:01 vps CROND[16455]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 10 15:54:01 vps CROND[16587]: (root) CMD (root /home/websites/public_html/admin/functions/open.sh)
Jul 10 15:54:01 vps CROND[16589]: (root) CMD (/usr/lib64/sa/sa1 1 1)
The script is programmed to run the following:
teste=`ps aux | grep web_socket | grep -v grep`;
# Testando se o IM gaim está rodando
if [ "$teste" ];
then
echo "Socket ON"
else
echo "Socket OFF"
killall php -q web_socket2.php
php -q web_socket2.php &
fi
Briefly is a verifier to see if the service socket is active, if it is not should close the traces of the service and activate it
Check the cron log with the " Tail -fn 50 /var/log/cron "command. And check what you’re saying there! Another thing for that " root " before the executable path ?
– Rafael Salomão
within the path there is no cron log, this is normal?
– Luiz Augusto Neto
No centos distro! Usually the log is in var/log cron file! Strange not to have, it may be possible that the person who set up the cron service has deleted the log.
– Rafael Salomão
Try to run the script directly on the command line.Wheel?
– Rafael Salomão
Come on, I wasn’t showing the log pq had dropped from ssh and I hadn’t noticed kkkk, it was wrong. Okay, first: I’m using root in front pq I saw on the web that was to use root, but I don’t know if it’s necessary. Second: the log that appeared to me is I’ll put in the post
– Luiz Augusto Neto
cron is running the routine as you can see in the log. What should this script do that it doesn’t? Have you tried running it directly inside the bash ?
– Rafael Salomão
You can play the script error inside a file like this: */1 * * * root /home/websites/public_html/admin/functions/open.sh > /home/websites/public_html/error.txt
– Rafael Salomão
I get it, I’ll put the txt and as soon as generate show for you, on what this script should do I’ll post in the post to you check.
– Luiz Augusto Neto
When I execute the command in hand it rotates normally
– Luiz Augusto Neto
also run in bash php -q web_socket2.php, it should be something inside it. If possible post its contents for me to see!
– Rafael Salomão
Boy, you’re a genius kkkk. Exaggerations the part you made me reason a little bit more here, as you can see above, I was calling the information in a generic way, and now I called the literal way and it worked, anyway, thanks man, it helped even here. I’ll post my solution.
– Luiz Augusto Neto
Don’t overdo it! I was going to post a note again, happy to have you solved! = P
– Rafael Salomão
Vlw man, I just need to set it right now as solved, please do so, I answered below, copy and paste in another answer so I can draw as solved and score you please. Vlw.
– Luiz Augusto Neto