Magento 1.9 cron job and PHP 7 - cron

I have installed Magento 1.9.2.2 with PHP 7 and I am using a cron job for shell execution to import products and export orders to my supplier. Unfortunately no processes are started and I am trying to figure out what is the issue.
The cron job is set as /usr/local/bin/php /home/"username"/domains/"mydomain"/public_html/cron.sh and gives the following respons:
#
# Magento
#
# NOTICE OF LICENSE
#
# This source file is subject to the Open Software License (OSL 3.0) # that is bundled with this package in the file LICENSE.txt.
# It is also available through the world-wide-web at this URL:
# x
# If you did not receive a copy of the license and are unable to # obtain it through the world-wide-web, please send an email # to x so we can send you a copy immediately.
#
# DISCLAIMER
#
# Do not edit or add to this file if you wish to upgrade Magento to newer # versions in the future. If you wish to customize Magento for your # needs please refer to x for more information.
#
# #category Mage
# #package Mage
# #copyright Copyright (c) 2006-2015 X.commerce, Inc. (x)
# #license x Open Software License (OSL 3.0)
#
# location of the php binary
if [ ! "$1" = "" ] ; then
CRONSCRIPT=$1
else
CRONSCRIPT=cron.php
fi
MODE=""
if [ ! "$2" = "" ] ; then
MODE=" $2"
fi
PHP_BIN=`which php`
# absolute path to magento installation
INSTALLDIR=`echo $0 | sed 's/cron\.sh//g'`
# prepend the intallation path if not given an absolute path
if [ "$INSTALLDIR" != "" -a "`expr index $CRONSCRIPT /`" != "1" ];then
if ! ps auxwww | grep "$INSTALLDIR$CRONSCRIPT$MODE" | grep -v grep 1>/dev/null 2>/dev/null ; then
$PHP_BIN $INSTALLDIR$CRONSCRIPT$MODE &
fi
else
if ! ps auxwww | grep "$CRONSCRIPT$MODE" | grep -v grep | grep -v cron.sh 1>/dev/null 2>/dev/null ; then
$PHP_BIN $CRONSCRIPT$MODE &
fi
fi
But if i use /usr/local/bin/php /home/"username"/domains/"mydomain"/public_html/cron.php it gives the following respons:
PHP Fatal error: Uncaught DivisionByZeroError: Modulo by zero in /home/"username"/domains/"mydomain"/public_html/app/code/core/Mage/Cron/Model/Schedule.php:165
Stack trace:
#0 /home/"username"/domains/"mydomain"/public_html/app/code/core/Mage/Cron/Model/Schedule.php(95): Mage_Cron_Model_Schedule->matchCronExpression('*', 10)
#1 /home/"username"/domains/"mydomain"/public_html/app/code/core/Mage/Cron/Model/Observer.php(193): Mage_Cron_Model_Schedule->trySchedule(1451563804)
#2 /home/"username"/domains/"mydomain"/public_html/app/code/core/Mage/Cron/Model/Observer.php(138): Mage_Cron_Model_Observer->_generateJobs(Object(Mage_Core_Model_Config_Element), Array)
#3 /home/"username"/domains/"mydomain"/public_html/app/code/core/Mage/Cron/Model/Observer.php(75): Mage_Cron_Model_Observer->generate()
#4 /home/"username"/domains/"mydomain"/public_html/app/code/core/Mage/Core/Model/App.php(1357): Mage_Cron_Model_Observer->dispatch(Object(Varien_Event_Observer))
#5 /home/"username"/domai in /home/"username"/domains/"mydomain"/public_html/app/code/core/Mage/Cron/Model/Schedule.php on line 165
Is the cron job (cron.sh) working properly, but is there a conflict due to PHP 7? What can I do to correct this?

The DivisionByZeroError exception must be resolved.
Prior to PHP 7, a division by zero would have raised a warning, which you are free to ignore and allows execution to continue in the current code path.

Related

Advice with Bash script to perform actions on certain conditions

I have written part of a small (hopefully) simple script that checks a URL for an error being returned using wget. It then outputs the error to a log file for alerting purposes. What I then want to do is for a service to be restarted automatically.
I will be running this check via a cronjob every minute, so if there is still an error after the service has been restarted already, I don't want the script to restart the service again.
Is there a elegant way to achieve this?
This is what I have so far, a wget check, if error code 5, output to the health.log file and restart nginx, however, I don't want this looping around restarting nginx every 60 seconds when running on a cronjob.
#!bin/bash
URL='http://some-url-here/'
LOG='/var/log/nginx/health.log'
wget -q $URL
if [ $? = 5 ] ; then
echo "$(date). SSL Error." > $LOG
sudo service nginx restart
exit
fi
Assumptions:
it's ok if we create a new file (restart.log), otherwise we could append a new line to $LOG
we'll only perform a restart attempt every 10 minutes (aka 600 seconds)
OP wants to append to the current $LOG (current code overwrites/replaces the entire file each time the script runs)
Proposed method:
use a new file to store the epoch time at which the last restart was attempted
before trying a restart we compare the current epoch with the saved epoch and only proceed (with the restart) if the difference in epochs is greater than 600 seconds
Modifying OP's current script:
#!/bin/bash # add "/" at start of shebang path
URL='http://some-url-here/'
LOG='/var/log/nginx/health.log'
RLOG='/var/log/nginx/restart.log'
touch "$RLOG"
wget -q $URL
if [ $? = 5 ] ; then
echo "$(date). SSL Error." >> "$LOG" # replace ">" with ">>" so that we append to $LOG
read -r prev_epoch < <(tail -1 "$RLOG") # retrieve epoch of last restart attempt
prev_epoch="${prev_epoch:-0}" # default to 0 if there is nothing in the file
printf -v curr_epoch '%(%s)T' # use printf builtin to grab current epoch and save in variable 'curr_epoch'
# curr_epoch=$((date '+%s')) # uncomment if 'printf -v' is not available in your system
delta=$((curr_epoch - prev_epoch))
if [[ "${delta}" -gt 600 ]] ; then
sudo service nginx restart
echo "${curr_epoch}" > "$RLOG" # replace ">" with ">>" if you want to maintain a history of restart epochs; the "tail -1" should insure we only grab the 'last' entry
exit
else
echo "it has only been ${delta} seconds since last restart attempt; skipping restart" >> "$LOG"
fi
fi

Oracle does not start on system startup

I need to configure oracle database of a remote server to start in system startup.
I followed this tutorial that is almost the same as others.
I am not allowed to restart the server, only can suggest the owner to do something on server.
The server configurations are similar to what the tutorial say but oracle database does not start at system startup. This is the /etc/dbora and /etc/init.d/oratab file contents:
dbora:
#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.
ORA_HOME=/u01/app/oracle/product/11.2.0/db_1
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
su $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" &
su $ORA_OWNER -c $ORA_HOME/bin/dbstart &
touch /var/lock/subsys/dbora
;;
'stop')
su $ORA_OWNER -c $ORA_HOME/bin/dbshut
su $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
rm -f /var/lock/subsys/dbora
;;
esac
oratab:
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
orcl:/u01/app/oracle/product/11.2.0/db_1:Y
orcl:/u01/app/oracle/product/11.2.0/db_1:N
What is wrong with these files?
leave only first row
**# Multiple entries with the same $ORACLE_SID are not allowed.**
#
#
orcl:/u01/app/oracle/product/11.2.0/db_1:Y

How to run command in cron job with external string

I need to run corn job every month to update software license.
The license is ready in text file on remote server (example: http://codebox.ir/soft/license.txt) and update every month.
license.txt content Example "tev3vv5-v343".
I want to grab the license and put in some command:
# update xxxx-xxxx
how can I make this?
CentOs 6.4
Write a script which fetches the file from your remoteserver
wget http://codebox.ir/soft/license.txt
Then you get the key out of that textfile and pipe it into your updatecommand
update `cat license.txt`
note the Backticks, so your script could look like this
#!/bin/sh
#
# This script fetches and updates the licensefile
#
wget http://codebox.ir/soft/license.txt;
update `cat license.txt`;
make the file executable
chmod +x updateLicense.sh
and put it in your crontab
cd /path/to/script;./updateLicense.sh
or to keep it compact, allthough i would check if the file is in an expected format first.
#!/bin/sh
#
# This script fetches and updates the licensefile
#
update `wget http://codebox.ir/soft/license.txt`;
And with checking if fetch succeeded
#!/bin/sh
#
# This script fetches and updates the licensefile
#
URL = http://codebox.ir/soft/license.txt
wget_output=$(wget -q "$URL")
if [ $? -ne 0 ]; then
update $wget_output
fi
No you can develop it further, i'd advise to check the format of the key before updating
#!/bin/sh
#
# This script fetches and updates the licensefile
#
# Define URL
URL = http://codebox.ir/soft/license.txt
# Fetch content
wget_output=$(wget -q "$URL")
# Check if fetch suceeded $? is the returnvalue of wget in this case
if [ $? -ne 0 ]; then
# Use mad Regexskillz to check format of licensekey and update if matched
if [[ $wget_output == [a-z0-9]+-[a-z0-9]+ ]] ; then update $wget_output; fi
fi
I'd also return some values to further raise quality of your script, also i'd pass the url and the regex into the function to keep the script reusable but that's a matter of taste

Command not found error in shellscript cron job for Plesk 11

Hoping for a bit of advice or guidance on this one. I am not very familiar with most of this stuff but have managed to navigate and test and check to get to this point. Solving one error at at time!
Running Plesk 11.0.9 I am attempting to set up a simple Cron job running a shell script to detect mailboxes that are approaching full, so that I or the user can be notified and solve the issue.
Running the script as the root user under the assumption that this will check all mailboxes.
The script is from the Plesk forum (last post http://forum.parallels.com/showthread.php?106635-Qmail-e-mail-quota-notification-script-for-Plesk-9-3-10) where many users seem to have had success however on running the job I get this error
/usr/local/psa/bin/mboxfull.sh: line 26: bc: command not found
/usr/local/psa/bin/mboxfull.sh: line 32: bc: command not found
This seems like a very generic 'what is written won't work' error so my search hasn't given me much direction as to how to correct this issue.
Full script below with the 'offending' lines marked. Any help of direction would be very much appreciated!
#! /bin/bash
# Mail quota reaching it's limit e-mail notification
# script for Plesk 9.3+ / Plesk 10 & Qmail
# Modified by "Scy" from the original script
# provided by "azur99" in Plesk forum:
# http://forum.parallels.com/showthread.php?t=71666
#setenv QMAILUSER 'do-not-reply'
MAILROOT=/var/qmail/mailnames
cd $MAILROOT > /dev/null
for DIR in *.*;do
cd $MAILROOT/$DIR
for MAILBOX in * ;do
if [ -d $MAILBOX ]
then
# look for specific mailbox quota file and set mailbox softquota
QUOTAFILE=$MAILROOT/$DIR/$MAILBOX/Maildir/maildirsize
# Fetching mailbox quota size in bytes
HARDQUOTA=$((`head -1 $QUOTAFILE | cut -d S -f1`))
if [ "$HARDQUOTA" -eq 0 ]; then
continue
fi
# Fetching space used by mailbox in bytes
(THIS IS LINE 26!) MBOXSPACE=$((`tail -n +2 $QUOTAFILE | cut -c1-12 | paste -sd+|bc`))
# Calculate the quota limit required for mail warning (85% for default)
SOFTQUOTA=$((10 * $HARDQUOTA / 100))
# Calculate mailbox usage percentage (with two decimals)
(THIS IS LINE 32) MBOXPERCENT=$(echo "scale=2; $MBOXSPACE*100/$HARDQUOTA" | bc)
# Check if the mailbox is full enough for warning, and if, send the warning mail
if [ $HARDQUOTA -gt 0 -a $MBOXSPACE -gt $SOFTQUOTA ]; then
# Let's generate the values in megabytes (with two decimals)
HARDQUOTA=$(echo "scale=2; $HARDQUOTA/1048576" | bc)
if [ "$(echo $HARDQUOTA | cut -c1)" = "." ] ; then HARDQUOTA="0"$HARDQUOTA
fi
MBOXSPACE=$(echo "scale=2; $MBOXSPACE/1048576" | bc)
if [ "$(echo $MBOXSPACE | cut -c1)" = "." ] ; then MBOXSPACE="0"$MBOXSPACE
fi
/usr/sbin/sendmail -t << EOF
To: $MAILBOX#$DIR
From: ******#*******.com
Bcc: ****#******.com
Subject: Your mailbox is almost full
Dear mail user,
Your e-mail $MAILBOX#$DIR is about to reach its maximum quota. You are using $MBOXSPACE MB ($MBOXPERCENT%) out of the maximum quota $HARDQUOTA MB.
We would kindly suggest you to delete some older messages and purge them to free some space in the mailbox. If the quota limit is reached, you won't be able to receive any new messages and the sender will receive 'mail quota exceeded' notifications.
Another option is to configure your POP3 mail client (e.g. Microsoft Outlook, Mozilla Thunderbird or Apple Mail) to delete the messages on the server mailbox every time the mail account is read.
This is an automated message, do not reply. If you require any assistance, please open a support ticket at http://*******/support.php .
EOF
fi
fi
done;
done;
line 26: bc: command not found
means that "bc" utility is not installed on your server.
Try to install it by following commands:
# yum install bc
or for debian-like systems:
# apt-get install bc

ssh & script problem

I am having a strange problem while doing ssh. I am not sure where the term Unmatched ` is coming from. What I need to do is run script that logs information of what I am doing on the terminal to text file. After ssh -
Sun Microsystems Inc. SunOS 5.8 Generic Patch October 2001
This is /etc/motd, last updated 3 Feb 2003.
To learn about the UCS system and other aspects of computing at UL-Lafayette
visit our home page http://helpdesk.louisiana.edu/ .
For more information about system use, contact the Help Desk, Stephens
Hall, Room 201, 482-5516 (x25516), during normal UL office hours; or send
e-mail to helpdesk#louisiana.edu.
ATTENTION:
Unsecure Telnet and FTP will be turned off soon.
Please make arrange to use ssh or sftp.
Putty(telnet) and WinSCP(ftp) would be a good replacement.
Unmatched `
d13.ucs.louisiana.edu% bash
bash-2.04$ script -a myInformation.txt
Script started, file is myInformation.txt
Unmatched `
d13.ucs.louisiana.edu%
When I tried to start the script with name myInformation.txt, you can see the message I am getting - Script started, file is myInformation.txt. But again I am getting that message Unmatched ` and is coming out of bash, as you can notice. What is the problem ? Any insights suggested would be very great.
Note: file with name myInformation.txt is being created but nothing goes in to it. As I have even tried running certain commands like ls and then exited the script with ctrl+d. But when I open the file, nothing is there.
.cshrc
`# #(#)cshrc 1.11 89/11/29 SMI
if ( `uname -s` == "Linux") then
# /etc/csh.{cshrc,login} set the csh and tcsh environments for Linux
# We just modify a few here:
set history=20 savehist=20
exit 0
endif
umask 027
# add here additional directories
set lpath = ()
set path = (~ ~/bin $lpath /usr/local/bin /usr/ccs/bin /usr/dt/bin /usr/openwin/bin /usr/bin /usr/sbin /usr/ucb .)
unset lpath
set noclobber
# Comment out the next line if you WANT core dumps (to debug via dbx,adb,gdb...)
limit coredumpsize 0
# An alternative to the above is to symlink ~/core to /dev/null ....
# Note that a core file can put you over quota, necessitating a command-line
# login [pick from the CDE Options menu] to be able to remove it.
if ( $?prompt == 0) exit
# Put here cmds suitable just for interactive c-shells
set history=20 savehist=20 time=10 autologout=28800
#set ignoreeof
set filec
set notify
#alias ls 'ls -F'
alias mail mailx
alias nissql /pkgs2/mysql/bin/mysql -h calvados.ucs.louisiana.edu -u cs4601d -p cs4601_d
.login
# #(#)local.login 1.5 98/10/03 SMI
if (`uname -s` == "Linux") then
exit 0
endif
if (! $?DT ) then
# Insert HERE and commands that are interactive, or alter the terminal
# characteristics. Thus, they will be bypassed if you start CDE and your
# .dtprofile invokes .login. Also remember /etc/.login is run first
# by non-CDE logins, and already sets some terminal characteristics.
# -- jpd#usl.edu
stty -istrip
endif
# environment variables
#setenv EXINIT 'set sh=/bin/csh sw=4 ai report=2'
#setenv MORE '-c'
#setenv PRINTER lw
setenv RNINIT '-I -e -m -S -i=11 -N -/ -h +hdate +hlines +hfrom -hdate-'
setenv LESS mQ
#setenv PRDEPT nnnn
setenv PAGER /usr/local/bin/less
#setenv EDITOR /usr/local/bin/emacs
setenv MANPATH /usr/local/man:/usr/local/perl/man:/usr/dt/man:/usr/openwin/man:/usr/man
#setenv AB2_DEFAULTSERVER http://pineau.ucs.louisiana.edu:8888/
setenv AB2_DEFAULTSERVER http://docs.sun.com:80/
setenv H_SPELL /dev/null
#
# if possible, start the windows system. Give user a chance to bail out
# To enable attempting openwin, set try_openwin=1 in the line below:
set try_openwin=0
if ( `tty` == "/dev/console" && $try_openwin) then
if ( "$TERM" == "sun" || "$TERM" == "sun-color" || "$TERM" == "AT386" ) then
if ( ${?OPENWINHOME} == 0 ) then
setenv OPENWINHOME /usr/openwin
endif
echo ""
echo -n "Starting OpenWindows in 5 seconds (type Control-C to interrupt)"
sleep 5
echo ""
$OPENWINHOME/bin/openwin
clear # get rid of annoying cursor rectangle
echo -n "Automatically logging out (type Control-C to interrupt)"
sleep 5
logout # logout after leaving windows system
endif
endif
unset try_openwin
The extra ` seems to be right there in the very beginning of your .cshrc.
...except of course if you are running bash as you say. What's the output of ps?

Resources