How can we use crontab in OCI DBCS - Oracle Cloud
To view crontab, we may need to use
# cat /etc/crontab
to add a job, we may need to use "vi"
# vi /etc/crontab
1. Copy the script to /home/oracle and change the ownership
[root@host opc]# cp /home/opc/test.sh /home/oracle/test.sh
[root@host opc]# chown oracle:oinstall test.sh
[root@host opc]# ls -ltr /home/oracle/test.sh
-rwxr-xr-x 1 oracle oinstall 27 Jan 2 18:35 test.sh
2. Change the ownership of log file
[root@host opc]# chown oracle:oinstall /tmp/test.log
[root@host opc]# ls -ltr /tmp/test.log
-rw-r--r-- 1 oracle oinstall 56 Jan 2 18:38 test.log
3. Modify the crontab job for user "oracle"
[root@host opc]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
*/1 * * * * oracle /home/oracle/test.sh >/dev/null 2>&1
4. Monitor the log
Post a Comment
Post a Comment