Albert Widjaja
asked on
How to check if the Cron job is running or not ?
Hi People,
I have just edited a bash script and then put it into the Cron directory as below:
Is that enough to make it works hourly ?
Any suggestion and help would be greatly appreciated.
Thanks
The script is from: https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2058187
I have just edited a bash script and then put it into the Cron directory as below:
root@PRODVCSA3-VM [ /etc/cron.hourly ]# chmod 700 /etc/cron.hourly/mon_disk_space
root@PRODVCSA3-VM [ /etc/cron.hourly ]# ls -laph
total 20K
drwxr-xr-x 2 root root 4.0K May 3 06:39 ./
drwxr-xr-x 81 root root 4.0K May 3 02:02 ../
-rwx------ 1 root root 414 Sep 13 2016 0anacron
-rwx------ 1 root root 1.2K May 3 06:39 mon_disk_space
-r-xr-xr-x 1 root root 1.1K Apr 8 14:38 netdumper
root@PRODVCSA3-VM [ /etc/cron.hourly ]#
Is that enough to make it works hourly ?
Any suggestion and help would be greatly appreciated.
Thanks
The script is from: https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2058187
ps -ef |grep cron
/etc/cron.... If not mistaken are run by Anacron...
/etc/cron.... If not mistaken are run by Anacron...
ASKER
Hi All,
Sorry for the late reply, as I'm not *NIX guy, I need some assistance in interpreting the result below:
Sorry for the late reply, as I'm not *NIX guy, I need some assistance in interpreting the result below:
root@PRODVCSA3-VM [ /etc/cron.hourly ]# cat /var/log/
audit/ cron invoked_procs messages.1.gz messages.6.gz procstate-20170505.gz remote/ stigreport.log vmware/
auth.log devicelist/ journal/ messages.2.gz postthaw/ procstate-20170506.gz restore/ suidlist/ vmware-vmsvc.log
btmp fbStatusInt.json lastlog messages.3.gz prefreeze/ procstate-20170507.gz rpmcheck/ tallylog wtmp
cloud-init.log firstboot/ lastlog.1.gz messages.4.gz procstate procstate-20170508.gz sa tallylog.1.gz
cm/ installer.log messages messages.5.gz procstate-20170504.gz procstate-20170509.gz sgidlist/ tmp-cmd.out
root@PRODVCSA3-VM [ /etc/cron.hourly ]# cat /var/log/cron
root@PRODVCSA3-VM [ /etc/cron.hourly ]#
root@PRODVCSA3-VM [ /etc/cron.hourly ]# ps -ef |grep cron
root 1127 1 0 May03 ? 00:00:03 /usr/sbin/crond -n
root 12814 11544 0 23:33 pts/0 00:00:00 grep --color=auto cron
root@PRODVCSA3-VM [ /etc/cron.hourly ]#
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Usin ntpdate as a cron is not advise able. Configure /etc/ntp.conf which will run ntpdate on boot and then ntpd will maintain and continue to deal with time drift limiting the possible time js pot 30 minutes or so...
ASKER
Hi Dr,
No I cannot see it configured anywhere:
@Arnold:
Cool thanks for sharing some tips in configuring NTP for Linux too ;-)
No I cannot see it configured anywhere:
root@PRODVCSA3-VM [ ~ ]# cat /etc/rsyslog.conf
################################################################################
############################# VMware Rsyslog Configuration ####################
################################################################################
###### Module declarations ######
$ModLoad imuxsock.so
$ModLoad imtcp.so # TLS
$ModLoad imptcp.so # TCP
$ModLoad imudp.so # UDP
$ModLoad omrelp.so # RELP
###### Common configuration ######
$EscapeControlCharactersOnReceive off
###### Template declarations ######
$template defaultLoc,"/var/log/vmware/%app-name%/%app-name%-syslog.log"
$template defaultFmt,"%timestamp:3:$:date-rfc3339% %syslogseverity-text% %app-name% %msg%\n"
$template vpxdLoc,"/var/log/vmware/%app-name%/%app-name%-syslog.log"
$template vpxdFmt,"%msg%\n"
$template rsyslogadminLoc,"/var/log/vmware/%app-name%/%app-name%-syslog.log"
$template rsyslogadminFmt,"%timestamp:3:$:date-rfc3339% %syslogseverity-text% %app-name% %msg%\n"
$template esxLoc,"/var/log/vmware/esx/%hostname%/%hostname%-syslog.log"
$template esxFmt,"%timestamp:3:$:date-rfc3339% %syslogseverity-text% %hostname% %app-name% %msg%\n"
$template defaultSystemLoc,"/var/log/messages"
###### Rule declarations ######
# TCP/UDP/rsyslog input ruleset declaration
$RuleSet all
# Make gtls driver the default
$DefaultNetstreamDriver gtls
# Shared certificate authority certificate
$DefaultNetstreamDriverCAFile /etc/vmware/vmware-vmafd/ca.crt
# Client certificate
$DefaultNetstreamDriverCertFile /etc/vmware/vmware-vmafd/machine-ssl.crt
# Client key
$DefaultNetstreamDriverKeyFile /etc/vmware/vmware-vmafd/machine-ssl.key
# Include the configuration for syslog relay
# _must_ be first to relay all messages
$IncludeConfig /etc/vmware-syslog/syslog.conf
# vmware services
:programname, isequal, "applmgmt-audit" ?defaultLoc;defaultFmt
& stop
:programname, isequal, "vmdird" ?defaultLoc;defaultFmt
& stop
:programname, isequal, "vmafdd" ?defaultLoc;defaultFmt
& stop
:programname, isequal, "vmcad" ?defaultLoc;defaultFmt
& stop
:programname, isequal, "vmdnsd" ?defaultLoc;defaultFmt
& stop
:programname, isequal, "rbd" ?defaultLoc;defaultFmt
& stop
:app-name, startswith, "rsyslog" ?rsyslogadminLoc;rsyslogadminFmt
& stop
:programname, isequal, "vmon" ?defaultLoc;defaultFmt
& stop
# vpxd-event
# Do not store events because of burst/size concerns
if $fromhost contains $$myhostname and
$app-name == 'vpxd' and
$msg startsWith ' Event ' then stop
if $fromhost-ip == '127.0.0.1' and
$app-name == 'vpxd' and
$msg startsWith ' Event ' then stop
# vpxd
if $fromhost contains $$myhostname and $app-name == 'vpxd' then ?vpxdLoc;vpxdFmt
& stop
if $fromhost-ip == '127.0.0.1' and $app-name == 'vpxd' then ?vpxdLoc;vpxdFmt
& stop
# localhost
if $fromhost contains $$myhostname then ?defaultSystemLoc
& stop
#localhost
:fromhost-ip, isequal, "127.0.0.1" ?defaultSystemLoc
& stop
# ESX rules
# Define large LinkedList action queue with 2K msgs cap to accomodate 100 ESXs
$ActionQueueSize 2000
# Do not choke ESXs, rather start dropping messages after queue is 97.5% full
$ActionQueueDiscardMark 1950
$ActionQueueDiscardSeverity 0
$ActionQueueTimeoutEnqueue 1
# VC syslog server log collection
*.* ?esxLoc;esxFmt
###### Input server declarations ######
# Setup input flow
$DefaultRuleset all
$InputPTCPServerBindRuleset all
$InputPTCPServerRun 514
$InputUDPServerBindRuleset all
$UDPServerRun 514
$InputTCPServerBindRuleset all
$InputTCPServerStreamDriverMode 1
$InputTCPServerStreamDriverAuthMode anon
$InputTCPServerRun 1514
root@PRODVCSA3-VM [ ~ ]#
@Arnold:
Cool thanks for sharing some tips in configuring NTP for Linux too ;-)
Not ..
Not sure I understand what you are after.
ps -ef | grep -I cron
Rsyslog has multiple options
Your log points that this is a VMware env.
Not sure I understand what you are after.
ps -ef | grep -I cron
Rsyslog has multiple options
Your log points that this is a VMware env.
ASKER
Yes Arnold,
This is VMware VCenter Virtual Appliance:
I need to know and make sure that there is Cron Job process running to execute the mon_disk_space script which sends me the alert when the VCSA disk space is running out.
This is VMware VCenter Virtual Appliance:
root@PRODVCSA3-VM [ ~ ]# ps -ef | grep -I cron
root 1127 1 0 May03 ? 00:00:03 /usr/sbin/crond -n
root 7683 7605 0 02:57 pts/0 00:00:00 grep --color=auto -I cron
root 55348 1 0 02:01 ? 00:00:00 /usr/sbin/anacron -s -S /var/spool/anacron
root@PRODVCSA3-VM [ ~ ]# uname -a
Linux PRODVCSA3-VM.domain.com 4.4.8 #1-photon SMP Fri Oct 21 20:13:51 UTC 2016 x86_64 GNU/Linux
root@PRODVCSA3-VM [ ~ ]#
I need to know and make sure that there is Cron Job process running to execute the mon_disk_space script which sends me the alert when the VCSA disk space is running out.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, Arnold,
Glad to hear that it is running fine now so I do not need to worry about the disk space.
The VCSA so far that I know can be monitored just by setting this script.
Unless you know some other way of monitoring VCSA ?
Glad to hear that it is running fine now so I do not need to worry about the disk space.
The VCSA so far that I know can be monitored just by setting this script.
Unless you know some other way of monitoring VCSA ?
The point of monitoring depending on your setup.
Remote monitoring such ñagios, zabbix, etc. provides a way for a remote system to connect to an agent/application/script configured on this system and check whether ctond is running. If not after two/three attempts over 15 seconds for example generate a notification to and/or take corrective action.
This same process can check logs of vcsa, run other commands that could actually checked and log the space use ......
There are many options limited only by your needs.
SNMP is another possible way to monitor a system pull running processies .......
Remote monitoring such ñagios, zabbix, etc. provides a way for a remote system to connect to an agent/application/script configured on this system and check whether ctond is running. If not after two/three attempts over 15 seconds for example generate a notification to and/or take corrective action.
This same process can check logs of vcsa, run other commands that could actually checked and log the space use ......
There are many options limited only by your needs.
SNMP is another possible way to monitor a system pull running processies .......
ASKER
Great,
Many thanks Arnold for the sharing.
As per this Thread question scope, I just need the confirmation and it seems to be running as per your response.
Many thanks Arnold for the sharing.
As per this Thread question scope, I just need the confirmation and it seems to be running as per your response.
To see if it's running, look in the cron log. When a cron job is started, it's logged, per the example below.
Open in new window