Skip to content

Instantly share code, notes, and snippets.

@tsu-nera
Created October 29, 2017 09:46
Show Gist options
  • Save tsu-nera/1520ecec722790f7ccd353fa7900b2a9 to your computer and use it in GitHub Desktop.
Save tsu-nera/1520ecec722790f7ccd353fa7900b2a9 to your computer and use it in GitHub Desktop.
#!/usr/bin/python2
import subprocess
import time
exec_path = "/home/tsu-nera/tmp/a.out"
core_path = "/home/tsu-nera/tmp/core"
bt_path = "/home/tsu-nera/tmp/backtrace"
core_time = subprocess.check_output(['ls', '-l', core_path]).split()
bt_time = subprocess.check_output(['ls', '-l', bt_path]).split()
core_time_p = time.strptime(core_time[7], "%H:%M")
bt_time_p = time.strptime(bt_time[7], "%H:%M")
if core_time_p > bt_time_p:
with open(bt_path, 'w') as f:
subprocess.call(['gdb', '-q', '-n', '-ex', 'bt', '-batch',
exec_path, core_path], stdout=f)
@tsu-nera
Copy link
Author

[Unit]
Description=get backtrace
After=syslog.target
[Service]
Type=oneshot
ExecStart=/usr/bin/bt.py
[Install]
WantedBy=multi-user.target

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment