{"id":410,"date":"2009-07-07T13:54:34","date_gmt":"2009-07-07T18:54:34","guid":{"rendered":"http:\/\/www.gamescheat.ca\/?p=410"},"modified":"2019-09-04T19:57:40","modified_gmt":"2019-09-05T00:57:40","slug":"auditing-the-cron-jobs-scheduled-on-the-unix-or-linux-server","status":"publish","type":"post","link":"http:\/\/www.gamescheat.ca\/?p=410","title":{"rendered":"Auditing the cron jobs scheduled on the Unix or Linux server."},"content":{"rendered":"<p>I have recently taken ownership of a Solaris 5.9 server and am in the process of migrating the applications over to a recent release.  I decided to audit the applications and configuration of all the apps installed.  One of the very long list of items I needed to figure out is the cron job,i.e. any automated scripts persormed by the system.  I will explain the method I used to create a complete inventory of all cron jobs belonging to the administrator and users.<\/p>\n<p>Cron jobs are generally stored in the default path of \/var\/spool\/cron\/crontabs.  This path is common for most Unix and Linux versions.  The easiest way to determine if a cron job is running is to goto \/var\/spool\/cron\/crontabs and list the files.  You can cat the file to see the scheduled job.<\/p>\n<p>I was only concerned about the scheduled jobs for all active userids and wanted to make sure that I captued them all.<\/p>\n<p>The first thing I did was to list all active user accounts using the listusers command and redirecting the output to a file all_user_names. See the example below.<\/p>\n<p># listusers > all_user_names<\/p>\n<div style=\"float: left;\"><div style=\"margin: 15px 15px 15px 15px\";><script type=\"text\/javascript\"><!--\ngoogle_ad_client = \"pub-3319935785736004\";\ngoogle_alternate_color = \"FFFFFF\";\ngoogle_ad_width = 300;\ngoogle_ad_height = 250;\ngoogle_ad_format = \"300x250_as\";\ngoogle_ad_type = \"text_image\";\ngoogle_ad_channel =\"\";\ngoogle_color_border = \"cccccc\";\ngoogle_color_link = \"cc0000\";\ngoogle_color_bg = \"ffffff\";\ngoogle_color_text = \"000000\";\ngoogle_color_url = \"008000\";\n\/\/--><\/script>\n<script type=\"text\/javascript\"\n  src=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">\n<\/script><\/div><\/div><p>You can view the file one page at a time using more, I copied the file to my desktop and inported it into Excel.  This way I could then take notes.<\/p>\n<p># more all_user_names<\/p>\n<p>You need to login as each user to see if they have any cron job.  Since I did not know the password for each user accounts I simply used to su \u2013 user_name command to logon as the user.  This will not prompt for password if you are already logged in as root or superuser.<\/p>\n<p># su \u2013 andrew<\/p>\n<p>After loggin in as the user, run the command crontab -l to display any scheduled job.<\/p>\n<p>server_promtp% crontab -l<br \/>\n# This command helps clean up user accounts.<br \/>\n1 0 * * 0 rm \/home\/andrew\/*.log > \/dev\/null 2>&1<\/p>\n<p>In the above example the # indicates a comment follows. All files with the extnsion .log is deleted very Sunday at 12:01 am.<\/p>\n<p>If you get the message crontab: can\u2019t open your crontab file, then it means that there are no schedule job for the the user.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have recently taken ownership of a Solaris 5.9 server and am in the process of migrating the applications over to a recent release. I decided to audit the applications and configuration of all the apps installed. One of the&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/www.gamescheat.ca\/?p=410\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[19],"tags":[21,55,35],"_links":{"self":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts\/410"}],"collection":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=410"}],"version-history":[{"count":1,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts\/410\/revisions"}],"predecessor-version":[{"id":411,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts\/410\/revisions\/411"}],"wp:attachment":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=410"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}