Tuesday, July 16, 2013

Python Crontab Simple usage

pip install python-dateutil python-crontab

from crontab import CronTab
user_cron = CronTab('myuser')
command = "/usr/bin/ls -la"
comment = "Run"
job = user_cron.new(command=command, comment=comment)
job.minute.every(5)
job.is_valid()
user_cron.write("outfile.tab")

Redhat/Debian Update Support

Preventing Kernel Updates in Linux
Ubuntu/Debian
http://www.howtogeek.com/howto/10606/how-to-hide-kernel-updates-in-ubuntu/

RedHat
http://www.howtogeek.com/50898/how-to-prevent-yum-from-updating-the-kernel/

List Available updates in Linux
Debian
aptitude search '?upgradable'

Redhat
sudo yum list updates
http://yum.baseurl.org/wiki/YumCommands


Automatic Security Updates
Ubuntu
https://help.ubuntu.com/community/AutomaticSecurityUpdates


Download only packages without installing
Redhat
yum install -y yum-downloadonly
yum install httpd -y --downloadonly --downloaddir=/my/download/dir/
http://www.cyberciti.biz/faq/yum-downloadonly-plugin/

Ubuntu
apt-get -d, --download-only ...

Screenshots from Python and Phantomjs

Copied from Pykler's Stackoverflow answer:
http://stackoverflow.com/questions/13287490/is-there-a-way-to-use-phantomjs-in-python

  1. Install NodeJS
  2. npm -g install phantomjs
  3. pip install selenium 
from selenium import webdriver
driver = webdriver.PhantomJS()
driver.set_window_size(1024, 768) # optional
driver.get('https://google.com/')
driver.save_screenshot('screen.png') # save a screenshot to disk
sbtn = driver.find_element_by_css_selector('button.gbqfba')
sbtn.click()