template.crontab #28

  • //
  • guest/
  • russell_jackson/
  • sdp/
  • Server/
  • Unix/
  • p4/
  • common/
  • etc/
  • cron.d/
  • template.crontab
  • View
  • Commits
  • Open Download .zip Download (6 KB)
MAILTO=REPL_MAILTO
MAILFROM=REPL_MAILFROM
PATH=/p4/common/bin:/p4/REPL_INSTANCE/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:
SHELL=/bin/bash

# Times are all preset to times that make sense based on UTC time with most users in PST.

# common tasks

# Commented out since this is only used when the crontab is checked in and updated from Perforce.
# */60 * * * * [ -e /p4/p4.crontab ] && crontab /p4/p4.crontab > /dev/null 2>&1

INSTANCE=REPL_INSTANCE
# Master Verify - Uncomment this line if you do not have any replica servers.
# 5 4 * * 6 [ -e /p4/common/bin ] && /p4/common/bin/run_if_master.sh ${INSTANCE} /p4/common/bin/p4verify.py ${INSTANCE}

# Run the weekly maintenance script to clean up old users, labels, workspaces and changelists. Be sure to set up the maintenance.cfg file.
0 16 * * * /p4/common/bin/run_if_master.sh ${INSTANCE} /p4/sdp/Maintenance/maintenance ${INSTANCE}
0 16 * * * /p4/common/bin/run_if_edge.sh ${INSTANCE} /p4/sdp/Maintenance/edge_maintenance ${INSTANCE}

# Run p4 unlock -x on edge servers every six hours to remove exclusive locks that shouldn't be there.
0 */6 * * * [ -e /p4/common/bin ] && /p4/common/bin/run_if_master.sh ${INSTANCE} p4 unlock -x > /dev/null 2>&1
0 */6 * * * [ -e /p4/common/bin ] && /p4/common/bin/run_if_edge.sh ${INSTANCE} p4 unlock -x > /dev/null 2>&1

# Update the limits group to make sure all users are listed in it.
*/60 * * * * [ -e /p4/common/bin ] && /p4/common/bin/run_if_master.sh ${INSTANCE} /p4/common/bin/update_limits.py ${INSTANCE}

# Checkpoints
# Run recreate_db_checkpoint.sh on the first Saturday afternoon in Jan. and July.
# 5 5 * * 6 [ $(date +\%d) -le 07 ] && /p4/common/bin/run_if_master.sh ${INSTANCE} /p4/common/bin/rotate_journal.sh ${INSTANCE}
# 5 6 * * 6 [ $(date +\%d) -le 07 ] && /p4/common/bin/run_if_master.sh ${INSTANCE} /p4/common/bin/recreate_db_checkpoint.sh ${INSTANCE}

# If you enable to recreate_db_checkpoint.sh, be sure to change 0-6 to 0-5 below.
5 4 * * 0-6 [ -e /p4/common/bin ] && /p4/common/bin/run_if_master.sh ${INSTANCE} /p4/common/bin/rotate_journal.sh ${INSTANCE}
5 5 * * 0-6 [ -e /p4/common/bin ] && /p4/common/bin/run_if_master.sh ${INSTANCE} /p4/common/bin/daily_checkpoint.sh ${INSTANCE}

35 6 * * 6 [ $(date +\%d) -le 07 ] && /p4/common/bin/run_if_edge.sh ${INSTANCE} /p4/common/bin/recreate_db_checkpoint.sh ${INSTANCE}

# If you enable to recreate_db_checkpoint.sh, be sure to change 0-6 to 0-5 below.
35 6 * * 0-6 [ -e /p4/common/bin ] && /p4/common/bin/run_if_edge.sh ${INSTANCE} /p4/common/bin/daily_checkpoint.sh ${INSTANCE}

# Replica Tasks

# Verify
# Use the -P parameter to run a parallel verify on the replica servers.
5 21 * * 6 /p4/common/bin/run_if_replica.sh ${INSTANCE} /p4/common/bin/p4verify.py ${INSTANCE} -P 60
# */10 * * * * /p4/common/bin/run_if_replica.sh ${INSTANCE} /p4/common/bin/verify_shelves.sh ${INSTANCE} 50

# Sync checkpoints from master
0 21 * * 1,3,5 [ -e /p4/common/bin ] && /p4/common/bin/run_if_replica.sh ${INSTANCE} /p4/common/bin/sync_replica.sh ${INSTANCE}
# Run recreate_db_checkpoint.sh on the first Saturday afternoon in Jan. and July.
5 22 * * 6 [ $(date +\%d) -le 07 ] && /p4/common/bin/run_if_replica.sh ${INSTANCE} /p4/common/bin/recreate_db_sync_replica.sh ${INSTANCE}

# If you can't run the scripts above due to rsync issues, then run this one instead.
# 0 5 * * 0-5 [ -e /p4/common/bin ] && /p4/common/bin/run_if_replica.sh ${INSTANCE} /p4/common/bin/replica_cleanup.sh ${INSTANCE}

# Replica Status
*/6 * * * * [ -e /p4/common/bin ] && /p4/common/bin/run_if_replica.sh ${INSTANCE} /p4/common/bin/replica_status.sh ${INSTANCE} > /dev/null
*/6 * * * * [ -e /p4/common/bin ] && /p4/common/bin/run_if_edge.sh ${INSTANCE} /p4/common/bin/replica_status.sh ${INSTANCE} > /dev/null

# Cache Purge on Edge servers that use lbr.replication=cache
# Comment out this line if you are not running with that config.
*/60 * * * * /p4/common/bin/run_if_edge.sh ${INSTANCE} /p4/common/bin/cacheclean.sh ${INSTANCE}

# Clean structured logs that aren't rotating
0 1 * * * [ -e /p4/common/bin ] && /p4/common/bin/run_if_replica.sh ${INSTANCE} rm -f /p4/${INSTANCE}/logs/*.csv > /dev/null

# ----------------------------------------------------------------------------
# Health / monitoring tasks (ported from upstream SDP)
# ----------------------------------------------------------------------------

# Journal disk-space watch: warn (and rotate) when the P4JOURNAL partition gets
# low. Args: <warnThreshold> <sendWarnAlert> <rotateThreshold> <alertOnRotate>.
30 * * * * [ -e /p4/common/bin ] && /p4/common/bin/run_if_master.sh ${INSTANCE} /p4/common/bin/journal_watch.sh ${INSTANCE} 20\% TRUE 10\% TRUE

# Service sanity smoke test (can it run p4, connect, see depots, correct owner).
15 * * * * [ -e /p4/common/bin ] && /p4/common/bin/run_if_master.sh ${INSTANCE} /p4/common/bin/p4sanity_check.sh ${INSTANCE} > /dev/null

# Weekly SDP health report (read-only; writes a timestamped report under /tmp).
0 7 * * 1 [ -e /p4/common/bin ] && /p4/common/bin/run_if_master.sh ${INSTANCE} /p4/common/bin/sdp_health_check.sh ${INSTANCE} > /dev/null

# Weekly full SDP verification. DISABLED by default: tune the -skip list first for
# this fork's older layout or it will report expected failures. Enable once you
# have confirmed the appropriate skip list.
# 0 6 * * 1 [ -e /p4/common/bin ] && /p4/common/bin/run_if_master.sh ${INSTANCE} /p4/common/bin/verify_sdp.sh ${INSTANCE} -L off -skip systemd,version,masterid

# Standby alternative to sync_replica.sh: request a checkpoint be produced at the
# next master journal rotation. Enable on standbys INSTEAD of sync/recreate if you
# use that workflow (leave disabled otherwise).
# 0 20 * * * [ -e /p4/common/bin ] && /p4/common/bin/run_if_replica.sh ${INSTANCE} /p4/common/bin/request_replica_checkpoint.sh ${INSTANCE}
# Change User Description Committed
#28 32803 Russell C. Jackson (Rusty) Modernize russell_jackson SDP fork from upstream 2025.2.

- Port modern p4d features: partitioned/readonly clients, upgrade-safety (p4
  storage -w / p4 upgrades polling), checkpoint/replica/edge tooling, proxy &
  broker SSL trust, modern p4login, dir-ownership preflight.
- Add scripts: get_p4_binaries.sh (renamed from helix), ccheck.sh, verify_sdp.sh,
  sdp_health_check.sh, journal_watch.sh, load_checkpoint.sh, refresh_P4ROOT,
  request_replica_checkpoint.sh, keep_offline_db_current.sh, gen_sudoers.sh, etc.
- Migrate configurables to configurables.cfg applied via ccheck.sh -fix; slim
  configure_new_server.sh to setup-only.
- upgrade.sh: dry-run default, verified clean rollback point.
- Fixes from multi-agent review (rsync byte/KB+comma, cfg field counts, version
  thresholds, etc.).

See SDP_PORT_SCOPE.md for the full manifest.
#27 32238 Russell C. Jackson (Rusty) New p4review.py and a script to create a list of all the files in a large server.
#26 29364 Russell C. Jackson (Rusty) Updated to be a normal crontab now that I am managing cron via Ansible.
#25 29327 Russell C. Jackson (Rusty) Increased journal rotations
#24 29145 Russell C. Jackson (Rusty) Updates to make sync replica run on alternate days to handle large checkpoints better.
#23 29139 Russell C. Jackson (Rusty) Added check for 2GB of free space in offline db before allowing scripts to proceed.
#22 29056 Russell C. Jackson (Rusty) Forgot to comment new line.
#21 29053 Russell C. Jackson (Rusty) Changed crontab to UTC and fixed recreate_db_checkpoint.sh to replay journals to offline db before stopping the service to reduce the downtime.
#20 28972 Russell C. Jackson (Rusty) Commented out kill_idle.
#19 28952 Russell C. Jackson (Rusty) Corrected wweekly typo.
#18 28939 Russell C. Jackson (Rusty) Modified unlock to only run every six hours.
#17 28937 Russell C. Jackson (Rusty) Commented things out to work better with Ansible installs.
#16 28933 Russell C. Jackson (Rusty) Modified crontab to better suit current environment.
#15 28869 Russell C. Jackson (Rusty) Added kill_idle.sh to crontab and modified kill_idle.sh to use p4 monitor terminate and removed 1 hour ignore.
#14 28171 Russell C. Jackson (Rusty) Crontab updates.
#13 28016 Russell C. Jackson (Rusty) Added verify_shelves.sh to crontab since Perforce doesn't always replicate them to standby servers.
#12 28005 Russell C. Jackson (Rusty) Fixed missing OFFLINECHECKPOINTNUM issue and fixed entries in template.p4.crontab.
#11 26942 Russell C. Jackson (Rusty) Changed crontab to run cacheclean hourly with the new free space check.
#10 24675 Russell C. Jackson (Rusty) Fixed bugs in sdputils.py and scripts using it.
Converted to standard 2 space spacing, removed copyright stuff.
#9 24138 Russell C. Jackson (Rusty) Added the line to run the p4cachepurge.
Commented though so it has to be turned on to run.
#8 24080 Russell C. Jackson (Rusty) Redirect unlock to dev null and autoload the crontab.
#7 24077 Russell C. Jackson (Rusty) Added cron jobs to run p4 unlock -x
#6 24075 Russell C. Jackson (Rusty) Added maintenance and edge_maintenance to crontab, created edge_maintenance and updated maintenance.
#5 22836 Russell C. Jackson (Rusty) Added the -P flag to the verify on replica servers to run in parallel.
#4 22812 Russell C. Jackson (Rusty) Added missing #.
#3 22805 Russell C. Jackson (Rusty) Commented out master verify as the default, and changed replica verify to run quarterly.
#2 22803 Russell C. Jackson (Rusty) Added replica status for the edge server.
#1 22693 Russell C. Jackson (Rusty) Branched a Unix only version of the SDP.
Removed extra items to create a cleaner tree.
Moved a few items around to make more sense without Windows in the mix.