LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-02-2011, 02:48 AM   #1
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561

Rep: Reputation: 57
Realisation of a "Crontab" with Bash


Hi,

There is a bash script that is launched every 1 minutes, and I plan to use it for various things for multimedia.

I wanna have HH:MM and eventually the day that if matches or superior, then activate (run) given bash script.

If PC is turned off, then it should forget it and skip.

Would you have some ideas how it could be made. With locks?

$HOME/.bashcrontab would contain the ini file (as crontab -e)

thanks
 
Old 11-02-2011, 04:35 AM   #2
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Is there a reason why you don't use at for this? You are almost certainly already running the atd daemon which provides exactly this as a service. See man 1 at for details.
 
Old 11-02-2011, 10:31 AM   #3
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561

Original Poster
Rep: Reputation: 57
Quote:
Originally Posted by Nominal Animal View Post
Is there a reason why you don't use at for this? You are almost certainly already running the atd daemon which provides exactly this as a service. See man 1 at for details.
yes:
from bash script, how could you add a line? simple answer

not possible, nor working:
Code:
 echo "0 7,11  *       *       *       cd ;  sh script.sh" < crontab -e
 
Old 11-02-2011, 11:18 AM   #4
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Quote:
Originally Posted by frenchn00b View Post
from bash script, how could you add a line? simple answer
I'm sorry, I don't understand the question. What do you mean by line?

Here is an example:
Code:
echo "(date ; ls -laF /tmp ) > /tmp/example.log" | at -t 201111022359
will run date ; ls -laF /tmp and redirect the output to /tmp/example.log on 2011-11-02 23:59:00 (Wed Nov 2 23:59:00), local time.

Quote:
Originally Posted by frenchn00b View Post
not possible, nor working:
As the crontab manpage instructs, the proper form of your command is
Code:
( crontab -l ; echo "0 7,11  *       *       *       cd && sh -c script.sh" ) | crontab -
Note also the small change in the command: It reads change to the home directory, and if that succeeds, run script.sh. The right side of && is only run if the left side succeeded.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 01:03 AM
BASH:find out if volume "foo"/folder "goo" can be written to SilversleevesX Programming 2 08-28-2010 10:03 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
C/C++ functions similar to BASH's "cp", "mv", "mkdir", etc? kornerr Programming 10 04-23-2006 09:48 AM
bash-2.05b# Xlib: extension "XFree86-DRI" missing on display ":0.0". citrus Linux - General 8 02-22-2004 10:43 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration