{"id":1055,"date":"2021-11-18T16:47:42","date_gmt":"2021-11-18T23:47:42","guid":{"rendered":"https:\/\/jeremywhittaker.com\/?p=1055"},"modified":"2021-11-19T10:27:07","modified_gmt":"2021-11-19T17:27:07","slug":"setting-up-python-algos-to-run-on-ubuntu-startup","status":"publish","type":"post","link":"https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/","title":{"rendered":"Setting up Python algos to run on Ubuntu startup using crontab"},"content":{"rendered":"\n<p>If you&#8217;re using Ubuntu or some other flavor of Linux you more than likely want your algorithm to start with the server. This is a pretty straightforward process.<\/p>\n\n\n\n<p>The first thing you&#8217;ll want to do is make sure cron is installed <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get update\nsudo apt-get install cron<\/code><\/pre>\n\n\n\n<p>Next run <strong>crontab -e<\/strong> select nano when it asks which editor. The code below can be used as a template The first two lines are just writing the current date to the log files on reboot so you know when the server was restarted. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@reboot date &gt;&gt; \/home\/me_jeremywhittaker_com\/AAII\/log.txt\n@reboot date &gt;&gt; \/home\/me_jeremywhittaker_com\/AAII\/errors.txt\n\n    \n<\/code><\/pre>\n\n\n\n<p>I actually am running two scripts for this particular strategy. Each one gets its own line of code. This basically tells it to run on on startup <strong>@reboot<\/strong> then the path to the script to execute, <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@reboot \/home\/me_jeremywhittaker_com\/queen_of_stonks\/queen_of_stonks_monitor.py >> \/home\/me_jeremywhittaker_com\/queen_of_stonks\/logs.txt 2>> \/home\/me_jeremywhittaker_com\/queen_of_stonks\/errors.txt \n\n@reboot \/home\/me_jeremywhittaker_com\/queen_of_stonks\/queen_of_stonks_trade.py >> \/home\/me_jeremywhittaker_com\/queen_of_stonks\/logs.txt 2>> \/home\/me_jeremywhittaker_com\/queen_of_stonks\/errors.txt\n<\/code><\/pre>\n\n\n\n<p>That&#8217;s it. We can now do a sudo reboot and our scripts should start with our server and save to the log files indicated. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re using Ubuntu or some other flavor of Linux you more than likely want your algorithm to start with the server. This is a pretty straightforward process&#8230;.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1055","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Setting up Python algos to run on Ubuntu startup using crontab - Jeremy Whittaker<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Setting up Python algos to run on Ubuntu startup using crontab - Jeremy Whittaker\" \/>\n<meta property=\"og:description\" content=\"If you&#8217;re using Ubuntu or some other flavor of Linux you more than likely want your algorithm to start with the server. This is a pretty straightforward process....\" \/>\n<meta property=\"og:url\" content=\"https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/\" \/>\n<meta property=\"og:site_name\" content=\"Jeremy Whittaker\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/WhittakerJeremy\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/WhittakerJeremy\" \/>\n<meta property=\"article:published_time\" content=\"2021-11-18T23:47:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-11-19T17:27:07+00:00\" \/>\n<meta name=\"author\" content=\"JeremyWhittaker\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"JeremyWhittaker\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/\"},\"author\":{\"name\":\"JeremyWhittaker\",\"@id\":\"https:\/\/new.jeremywhittaker.com\/#\/schema\/person\/ed0edfdefb3e180693efef453372980c\"},\"headline\":\"Setting up Python algos to run on Ubuntu startup using crontab\",\"datePublished\":\"2021-11-18T23:47:42+00:00\",\"dateModified\":\"2021-11-19T17:27:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/\"},\"wordCount\":159,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/new.jeremywhittaker.com\/#\/schema\/person\/ed0edfdefb3e180693efef453372980c\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/\",\"url\":\"https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/\",\"name\":\"Setting up Python algos to run on Ubuntu startup using crontab - Jeremy Whittaker\",\"isPartOf\":{\"@id\":\"https:\/\/new.jeremywhittaker.com\/#website\"},\"datePublished\":\"2021-11-18T23:47:42+00:00\",\"dateModified\":\"2021-11-19T17:27:07+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/new.jeremywhittaker.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Setting up Python algos to run on Ubuntu startup using crontab\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/new.jeremywhittaker.com\/#website\",\"url\":\"https:\/\/new.jeremywhittaker.com\/\",\"name\":\"Jeremy Whittaker\",\"description\":\"Research, software, markets, housing, and energy\",\"publisher\":{\"@id\":\"https:\/\/new.jeremywhittaker.com\/#\/schema\/person\/ed0edfdefb3e180693efef453372980c\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/new.jeremywhittaker.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/new.jeremywhittaker.com\/#\/schema\/person\/ed0edfdefb3e180693efef453372980c\",\"name\":\"JeremyWhittaker\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/c8ac20e6dfa86b5f27ce9bffee4851099770cbea5ae7338a274865bfbc8c0218?s=96&d=retro&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c8ac20e6dfa86b5f27ce9bffee4851099770cbea5ae7338a274865bfbc8c0218?s=96&d=retro&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c8ac20e6dfa86b5f27ce9bffee4851099770cbea5ae7338a274865bfbc8c0218?s=96&d=retro&r=g\",\"caption\":\"JeremyWhittaker\"},\"logo\":{\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/c8ac20e6dfa86b5f27ce9bffee4851099770cbea5ae7338a274865bfbc8c0218?s=96&d=retro&r=g\"},\"sameAs\":[\"http:\/\/www.jeremywhittaker.com\",\"https:\/\/www.facebook.com\/WhittakerJeremy\",\"https:\/\/www.linkedin.com\/in\/jeremywhittaker\/\"],\"url\":\"https:\/\/new.jeremywhittaker.com\/index.php\/author\/jeremywhittaker\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Setting up Python algos to run on Ubuntu startup using crontab - Jeremy Whittaker","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"Setting up Python algos to run on Ubuntu startup using crontab - Jeremy Whittaker","og_description":"If you&#8217;re using Ubuntu or some other flavor of Linux you more than likely want your algorithm to start with the server. This is a pretty straightforward process....","og_url":"https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/","og_site_name":"Jeremy Whittaker","article_publisher":"https:\/\/www.facebook.com\/WhittakerJeremy","article_author":"https:\/\/www.facebook.com\/WhittakerJeremy","article_published_time":"2021-11-18T23:47:42+00:00","article_modified_time":"2021-11-19T17:27:07+00:00","author":"JeremyWhittaker","twitter_card":"summary_large_image","twitter_misc":{"Written by":"JeremyWhittaker","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/#article","isPartOf":{"@id":"https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/"},"author":{"name":"JeremyWhittaker","@id":"https:\/\/new.jeremywhittaker.com\/#\/schema\/person\/ed0edfdefb3e180693efef453372980c"},"headline":"Setting up Python algos to run on Ubuntu startup using crontab","datePublished":"2021-11-18T23:47:42+00:00","dateModified":"2021-11-19T17:27:07+00:00","mainEntityOfPage":{"@id":"https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/"},"wordCount":159,"commentCount":0,"publisher":{"@id":"https:\/\/new.jeremywhittaker.com\/#\/schema\/person\/ed0edfdefb3e180693efef453372980c"},"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/","url":"https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/","name":"Setting up Python algos to run on Ubuntu startup using crontab - Jeremy Whittaker","isPartOf":{"@id":"https:\/\/new.jeremywhittaker.com\/#website"},"datePublished":"2021-11-18T23:47:42+00:00","dateModified":"2021-11-19T17:27:07+00:00","breadcrumb":{"@id":"https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/new.jeremywhittaker.com\/index.php\/2021\/11\/18\/setting-up-python-algos-to-run-on-ubuntu-startup\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/new.jeremywhittaker.com\/"},{"@type":"ListItem","position":2,"name":"Setting up Python algos to run on Ubuntu startup using crontab"}]},{"@type":"WebSite","@id":"https:\/\/new.jeremywhittaker.com\/#website","url":"https:\/\/new.jeremywhittaker.com\/","name":"Jeremy Whittaker","description":"Research, software, markets, housing, and energy","publisher":{"@id":"https:\/\/new.jeremywhittaker.com\/#\/schema\/person\/ed0edfdefb3e180693efef453372980c"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/new.jeremywhittaker.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/new.jeremywhittaker.com\/#\/schema\/person\/ed0edfdefb3e180693efef453372980c","name":"JeremyWhittaker","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c8ac20e6dfa86b5f27ce9bffee4851099770cbea5ae7338a274865bfbc8c0218?s=96&d=retro&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c8ac20e6dfa86b5f27ce9bffee4851099770cbea5ae7338a274865bfbc8c0218?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c8ac20e6dfa86b5f27ce9bffee4851099770cbea5ae7338a274865bfbc8c0218?s=96&d=retro&r=g","caption":"JeremyWhittaker"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/c8ac20e6dfa86b5f27ce9bffee4851099770cbea5ae7338a274865bfbc8c0218?s=96&d=retro&r=g"},"sameAs":["http:\/\/www.jeremywhittaker.com","https:\/\/www.facebook.com\/WhittakerJeremy","https:\/\/www.linkedin.com\/in\/jeremywhittaker\/"],"url":"https:\/\/new.jeremywhittaker.com\/index.php\/author\/jeremywhittaker\/"}]}},"_links":{"self":[{"href":"https:\/\/new.jeremywhittaker.com\/index.php\/wp-json\/wp\/v2\/posts\/1055","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/new.jeremywhittaker.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/new.jeremywhittaker.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/new.jeremywhittaker.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/new.jeremywhittaker.com\/index.php\/wp-json\/wp\/v2\/comments?post=1055"}],"version-history":[{"count":0,"href":"https:\/\/new.jeremywhittaker.com\/index.php\/wp-json\/wp\/v2\/posts\/1055\/revisions"}],"wp:attachment":[{"href":"https:\/\/new.jeremywhittaker.com\/index.php\/wp-json\/wp\/v2\/media?parent=1055"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/new.jeremywhittaker.com\/index.php\/wp-json\/wp\/v2\/categories?post=1055"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/new.jeremywhittaker.com\/index.php\/wp-json\/wp\/v2\/tags?post=1055"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}