Crontab does not execute script

0

I'm trying to run a script through centos crontab, I'm doing this:

crontab -e

Then I 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 correct, where am I going wrong?

Log Displayed:

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 scheduled to run as follows:

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

In short it is a checker to see if the socket service is active, if it is not it should close the traces of the service and activate it

    
asked by anonymous 10.07.2017 / 17:13

1 answer

1

I concluded the question as follows:

teste='ps aux | grep web_socket | grep -v grep';

if [ "$teste" ];
then
    echo "Socket ON"
else
    echo "Socket OFF"
    killall /usr/local/bin/php /home/websites/public_html/admin/functions/web_socket2.php
    sleep 3; /usr/local/bin/php -q /home/websites/public_html/admin/functions/web_socket2.php &
fi

That is, I was using a generic path, I just needed to add the literal path.

    
10.07.2017 / 21:45