Steve's Power Systems BlogPower BlogContactLog inRegister
  • Power Blog
  • Contact

  • Register

IBM Power Systems Blog

Power Systems
  • Front Page
  • Categories
  • Archives
  • Latest comments
  • « Stop using vi to edit /etc/rc.tcpip
  • Who is using all my CPU? »

Are you testing scripts with crontab?

Posted by steve on 10 Oct 2016 in AIX Tips, Scripts and One Liners, Command Line Tips

Are you using crontab to schedule scripts you are testing or developing before they go live?  I have seen a few system administrators running scripts via crontab entries when they need to run a one off script or they are testing new scripts.  Often, then crontab entry is forgotten and not removed, so cron may continue to schedule the script, which may have been deleted now.

As an example, someone was asked to run a script overnight as a one off, so the proceeded to add a cron job like the following example.  The current date is 3rd July.

30 20 3 7 * * /home/my_script.sh 1>/home/my_script.out 2>&1

So that night, the job ran as expected, but the crontab entry was not removed.  So every year, on the 3rd of July, the script will execute, if it still exists, otherwise it will produce an error in the cron log.

A much better way to schedule a one of script is to use the at command.  The at command actually uses cron to run the job, but the job is automatically deleted once it has been run.

Here are some examples on how to use the at command.  The lines after the at command are the scripts or commands you would like to run, followed by ctrl+d to submit the at job.

 

To run a job now:

at now

/home/my_script.sh 1>/home/my_script.out 2>&1

ctrl+d

 

To run a job in 1 hours time:

at now + 1 hour

/home/my_script.sh 1>/home/my_script.out 2>&1

ctrl+d

 

To run a job at this time tomorrow:

at now + 1 day

/home/my_script.sh 1>/home/my_script.out 2>&1

ctrl+d


To run a job at 20:00 tonight:

at 2000

/home/my_script.sh 1>/home/my_script.out 2>&1

ctrl+d


To list the at jobs you have scheduled:

at -l

root.1476169166.a Tue 11 Oct 17:59:26 2016

root.1476176400.a Tue 11 Oct 20:00:00 2016

root.1476176401.a Tue 11 Oct 20:00:01 2016


To delete an at job you have scheduled:

at -r root.1476176401.a

The root.1476176401.a at file is deleted.

 

 

Tags: AIXatcroncrontab

No feedback yet


Form is loading...

July 2026
Mon Tue Wed Thu Fri Sat Sun
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
 << <   > >>

IBM Power Systems Blog

IBM Power Systems - Administration, Tuning and Optimisation. These posts are my own personal opinions and comments only.

Search

Categories

  • All
  • AIX Tips
  • AIX Tuning
  • Command Line Tips
  • HMC Tips
  • LPM Information
  • NIM Tips
  • Performance Testing
  • Power System Affinity
  • PowerHA Tips
  • SRIOV and vNIC
  • Scripts and One Liners
  • VIO Server Tips

Recent Posts

  • AIX NIM Hints and Tips
  • Finding Multiple Install Sources for AIX
  • PowerHA and EMC Busy Devices
  • AIX Random Password Generation
  • VIO Server 3.1.0 and ssh host keys
  • VIO Server 3.1.0 Items to Review
  • Just when you thought you understood idle CPU time!!
  • 40Gbit Adapter Performance Testing
  • LPM Copy Time Statistics
  • IBM HMC Upgrades

Recent Comments

  • steve on How to configure IBM SRIOV Adapters
  • Howard Coles on How to configure IBM SRIOV Adapters
  • steve on AIX mpstat and lssrad part 1
  • Charin Kumjudpai on AIX mpstat and lssrad part 1
  • Gagandeep on LPM and multiple vSwitches
  • Fant Steele on VIO Server 3.1.0 and ssh host keys
  • steve on AIX NIM Hints and Tips
  • alan wilcox on AIX NIM Hints and Tips
  • steve on AIX buf_mode attribute for Virtual Ethernet Adapters
  • Bernhar on AIX buf_mode attribute for Virtual Ethernet Adapters
  • Gery on Reading VLANs from the SEA Adapter
  • steve on Reading VLANs from the SEA Adapter
  • patrice on Reading VLANs from the SEA Adapter
  • steve on Reading VLANs from the SEA Adapter
  • steve on AIX buf_mode attribute for Virtual Ethernet Adapters
  • Chris K. on AIX buf_mode attribute for Virtual Ethernet Adapters
  • jovi on AIX or VIOS Errors: 29FA8C20 and 7BFEEA1F
  • steve on AIX or VIOS Errors: 29FA8C20 and 7BFEEA1F
  • jovi on AIX or VIOS Errors: 29FA8C20 and 7BFEEA1F
  • steve on Creating EtherChannel Devices from Command Line

This collection ©2026 by Stephen Diwell • Contact • Help • Content Mangement System

Community software
Cookies are required to enable core site functionality.