Debian :: Bash Script Based On Time Of Day

Mar 25, 2016

I'm trying to get a bash script to do different things based on the time of day, but at least once a day the test fails:

Code: Select allNOW=$(date +%k%M)
if [[ "$NOW" -ge 1000 ]] && [[ "$NOW" -le 2200 ]];then
        alarm lon
else
        alarm loff
fi

This is the error, and line 59 is the second quoted above:

Code: Select all/home/electrolux/bin/ts.sh: line 59: [[: 059: value too great for base (error token is "059")

The script is run every minute, and this error only occurs at 12:59AM, or 00:59.

I presume the problem is either $NOW is being set to 059, or the testing is seeing 0059 as 059. I think the latter, because for the rest of midnight 'til 00:58 the script works. And with some Googling it seems that the leading 0 is making test treat the number as octal... is there a way to tell it it is decimal?

Perhaps this is just some poor time-testing code? Looking at it I don't think it will cope with set time period that crosses midnight..... there's probably just a command to do what I want, isn't there? I know I could have two different scripts cron'd for the different time periods, but it would be much more preferable to be just the one.

View 4 Replies


ADVERTISEMENT

General :: Debian Based - Arch Based - What Is The Practical Difference?

Jun 7, 2010

I notice that on DistroWatch, the descriptions include "debian based", "arch based", etc. For the newbie, is there any practical difference between the different bases, or is it a Coke vs Pepsi type question?

Is a distro based on Debian say, easier for a newbie to learn or work with than say one that is FreeBSD based?

View 9 Replies View Related

General :: Distro Should Use, Rpm Based Or Debian Based?

Feb 2, 2011

what distro should i use, rpm based or debian based?

View 2 Replies View Related

Programming :: Bash Script In Based Hosting?

Apr 4, 2010

i have a question in my mind.sorry if its irrelevant to this topic.Can i run bash script (which i currently run on cygwin) in linux based web hosting?

View 2 Replies View Related

General :: Denying Login Based On Time

May 1, 2010

i want to deny certain users based on time to login to my machine i am using CentOs 5.0 any sugestions?

View 2 Replies View Related

Ubuntu :: Conky For Network Traffic Based On Time

Dec 11, 2010

I have installed conky from soft manager after knowing its power today. I'm using 10.10. I want to design a conky script which monitor the network traffic ie total upload + download on monthly basis as I'm on limited internet plan which is too common here. I have free usage from 2am to 8am in the morning and want to exclude this traffic. So I'm in search of a custom script which can accomplish this.

View 1 Replies View Related

Software :: Way To Sort A Files Based On Creation Time

Jul 7, 2010

Code...

But I want to get the files in order which they created like file, file1 and file2

Any way to obtain this?

View 6 Replies View Related

General :: Bash Script Rename Files Based On Directory Name?

Mar 26, 2010

I'm pretty new to bash scripting, but I really want to wrap my head around it.What I'm trying to do is: From directory "A": Go in to all subdirectories and rename all files within icrementally according to the directory name. SO:

|-- Varian
| |-- FB1-page132.pdf.png
| |-- FB1-page133.pdf.png

[code]...

View 7 Replies View Related

Programming :: Creating A Text Based Menu Structure In Bash?

May 15, 2009

Is it possible to create a text based menu layout in bash were it is possible to browse through. The menu list should look something like this:

----------------------------------------
user: root
colour: blue
number: 4
animal: dog
----------------------------------------

At the start the cursor should blink at the r from root so that text can be entered. When pressing the enter the cursor should go to the b from blue and so on. the imported thing is that all the text is visible also beyond the position from the cursor.

View 4 Replies View Related

General :: Calculation Of Working Time Based On System Uptime

Jul 28, 2010

I know several tools that allow tracking time spend on different tasks / projects.Is there any existing tool for very very simplified work-time-tracking.I am an employee, come to the office, switch on my laptop directly. I have mostly around 1 hr lunchtime, but sometimes less, sometimes more.At around 18:00 I want to type one command in the console (or simple GUI would also be okay of course) that tells me:"1 hour overworked. Go home now! (came at 8:00, 1 hour standard lunch-break)."

View 1 Replies View Related

Software :: Best Console Based Calendar / Time Manager (or Backend)?

Jan 20, 2010

Looking for console based calendar / time manager (or backend)? Well is there a good one to be known? Maybe else than 'when'? Joe Barr has written a nice intro to the program in his column at linux. [URL]. Is there some backend and frontend that could be used? Or alternatively, could it be possible to have them on an Kerberos/Ldap system or exchange server? What are the best and multiplatform single cal database possibility?

View 1 Replies View Related

Ubuntu :: Bash Script - Run Different Rsync Cmds Based On Which Devices Are Mounted

Apr 2, 2010

having my data backed up properly, but it's also in different places (e.g. photos and music on separate flash drives), so I have a few rsync's that I can execute manually, drives are mounted. Unfortunately, it gets confusing very quickly, I'd like a simple bash script that goes something like this (this pseudo-code would be most like REXX):

pair.1 = (/dev/sdb1, /dev/mmcblkp01)
pair.2 = (/some/other/device, /yet/another/device)
for i = 1 to #pairs

[code]....

Seems simple enough, but I've never written a bash script and wouldn't know where to start.

View 5 Replies View Related

Programming :: Bash - Calling A Specific Variable Based On User Input?

May 3, 2011

I'm trying to call a specific variable based on a user selection. For example:

Code: Select a file:

[1] foo.tar
[2] bar.tar

Enter a selection: I have already coded each possible selection to have its own variable. If the user selects 2 I need to select $SELECTED_TAR2, or if they select 1 I need to select $SELECTED_TAR1 and then do something like this behind the scenes:

Code: cp /home/user/$SELECTED_TAR2 /home/user/backup/$SELECTED_TAR2

I was thinking something like this:

Code: echo "Enter a selection: "
read -e SELECTED_NUMBER
cp /home/user/$SELECTED_TAR$SELECTED_NUMBER /home/user/backup

[code]....

View 2 Replies View Related

Programming :: Bash-code To Rename Files Based On Config File

Apr 12, 2010

I'm writing a bash shell script that among various other things will traverse through a directory with hundreds of files and rename those who match a pattern found in a config file. It's expected that only about one in ten files will actually match, and those who don't, will simply just be ignored for this purpose.

This should for instance cause the file "dBase program file December 1987.prg" to be renamed "Clipper source code December 1987.prg", and conversely "C++ source August 1996.cpp" to be renamed "C source code August 1996.cpp" etc.A sample file such as "Random Data File.dat" should not be renamed here since it's not mentioned in the config file..What is the quickest, most elegant way to do this in bash?I am thinking of using bash's built-in regex matching combined with the /bin/rename utility, but don't quite know how to get started to catch this..I guess there are plenty ways of doing this in perl and elsewhere as well, but since this has to integrate into a pre-existing bash script, that's what I'm looking for.Anyone out there with a spare moment to offer a hint in the right direction?

View 14 Replies View Related

General :: Script To Execute A Command Based On The Last Modified Time Of A Folder

Oct 19, 2010

I need a script that executes a command based on a folder's last modified time.

if "/var/data" was modified in less than an hour then "/usr/local/etc/searchd stop" should be run

can we use "find -mmin +60 -type d" in conjunction with second command

View 1 Replies View Related

Security :: IPTABLES - Restrict Internet Access Based On Time Of Day And MAC Address

Feb 6, 2010

I am trying to configure my Linux router to restrict Internet access for one computer on my LAN. It needs to be restrictive based on the time of day and the days of the week. I am using the MAC address of the computer to single out the one computer that needs to be blocked. However, this is my first attempt at making any rules with iptables, and I am not sure if I am doing this right. If some one can take a look at this I would greatly appreciate it. This is what I have done so far.

Here is my thinking. Create a new target. Check the MAC address, if it is NOT the offending computer return to the default chain. If it is the offending computer check that we are between the allowed hours and dates and ACCEPT. If we are not within the time/date range then drop the packet.

Code:

Here I am trying to route all packets regardless of the computer on the LAN into the blocked_access chain for checking.

Code:

Is it a good idea to route all traffic through the blocked_access chain? I do run other servers that are accessible from the Internet, so I am not sure how this setup will affect that. I also use shorewall on the router to setup iptables for me. How would I integrate this with shorewall?

I am using squid to block access when he is using the web browser. However, he is still able to play games(World of Warcraft) and the like.

I am using Debian sid, iptable(1.4.6), shorewall(4.4.6), kernel 2.6.32-trunk-686.

View 7 Replies View Related

CentOS 5 Networking :: TIme Based Ethernet Interface Disable And Enable?

Mar 14, 2011

Im new to this Cent OS as well as Unix based Operating Systems. Please help me with the below requirement.My Company is a Serach based data collector from different websites like Google, Yahoo & many more..Collecting the data from the search engines is a issue for right now.. As many search engines are blocking us to search and retrive the date after some time.. Taking Google as example : Google Blocks my IP after every 30 mins of retriving.. Application is a Windows based & using Windows 2003 as the Server.. Would like to give a Dynamic IP to the Windows Server via 1st Ethernet Card & enable the 2nd Ethernet for the Internet..Eg : eth 0 = 192.168.1.1eth 1 = x.x.x.x (Public IP)I have check with few of my friends who told me to get Linux or Cent OS installed to do a interface disable after given time & enable a secondary device or virtual interface the next couple of seconds... Like eg : eth 1 = x.x.x.1 eth 2 = x.x.x.2 eth 3 = x.x.x.3 so on.. Would like the eth 1 to be down after 60 mins & eth 2 o be up & again after 60 mins of up time eth 2 down & eth 3 up.

View 6 Replies View Related

General :: Bash - Use A Graphical Or Text Based EDITOR On Logging In Locally Or Remotely?

Aug 17, 2010

I can set my EDITOR variable in my .bashrc to e.g. gedit, which is a nice graphical editor on ubuntu. But when I log in over PuTTY that editor will fail.What is the best way to detect if I'm logged in and can run a graphical editor, or not, and set EDITOR appropriately?

View 2 Replies View Related

Programming :: Bash Script: Sort Files Into Directory Based On Data In The File Name?

Sep 28, 2010

I have very little linux experience. And need some help with a bash script. I need to a script I can set cron to run to sort files out of a holding folder into final folders. It doesn't necessarily have to be bash, but I think it would be sufficient for this. File names are formatted as such when created: Dest-Date-Time-CID-Destination# I want the files to be moved from a all in one holding folder to a folder structure like this.

.../storage/year/month/day/Destination#/VarX(type)/hour/CID/'File'

I would need an if/else if/else statement to say if Dest = A set VarX = B If for example the file name was

infinity-20100927-17:00-1112223333-4445556666.wav

I would like the above file to end up moved from

.../holding

to

.../storage/2010/09/27/4445556666/Inbound/17/1112223333/infinity-20100927-17:00-1112223333-4445556666.wav

So the script will need to make directories based on information in the file name which is delimited by single dashes. Then move files from the holding folder to the newly created "sorted" folders.

View 15 Replies View Related

Debian :: Best Small -600mb Frugal Debian Or Debian-based Distro's?

Jul 17, 2009

I know of 3 at least so far Sidux and GRML and DRBL are there any others that are based on stabel or sid? or what? frugal as in like puppy, tinycore, dsl, etc nomadic like, usb, hd, etc?

View 14 Replies View Related

Programming :: Program A SH - Bash Program With Zenity To Play Radio Based On A Site?

Feb 15, 2011

I will have to code this. However I am lacking of time since I have too much to do. make a short code bash/dash to prompt the country with Zenity, then, get the PLS or m3u url and prompt with another zenity which radio to play. http://www.listenlive.eu/index.html

My code to get url's radio country.htm is:

Code:

View 2 Replies View Related

Debian :: Connection Breaks Time To Time / Sometimes Cannot Connect Automaticaly After Restart

Apr 22, 2010

Since the upgrade from Lenny to Squeeze on my Notebook Toshiba Satellite Pro U200 with Intel Pro/Wireless 3945 ABG I have wireless connection problems.The connection breaks time to time and sometimes cannot connect automaticaly after restart. BTW I didn't change anything on the wireless or network configurations on the notebook and on the wiereless router.

View 8 Replies View Related

Programming :: Bash Find Files On Time Help?

Mar 11, 2011

I am trying to find a nightly backup if it was successfully copied over, rename it and curl, but it's always passing the check even if the file is older than specified. From the command line it does as it should. Example is here;

Code:
find /backup -type f -mmin +4440 -exec echo "found" {} ;
- nothing returned (good). Then I change the time

[code].....

View 4 Replies View Related

Debian Configuration :: Restore From Hibernate Fails From Time To Time?

Apr 28, 2011

I have a Insprion 14R (N4010) and when I hibernate it will usually restore without a problem, but maybe 15% of the time it will reboot while loading. I would like to figure why, since I'd rather not lose anything... My swap space is 5.9GB, I have 4GB RAM (video uses 1gb, so I have 3gb usable)

lspci says

00:00.0 Host bridge: Intel Corporation Core Processor DRAM Controller (rev 18)
00:02.0 VGA compatible controller: Intel Corporation Core Processor Integrated Graphics Controller (rev 18)
00:16.0 Communication controller: Intel Corporation 5 Series/3400 Series Chipset HECI Controller (rev 06)

[code]....

I do have the hibernate package installed...

View 6 Replies View Related

General :: Bash - Script That Indicates Time The Server Was Offline?

May 18, 2010

Below is data taken from my dedicated server:

[Code]...

I need a script that I can run on an hourly basis that will:

1. Calculate the total downtime since the first date
2. The overall downtime percentage
3. Store this data in a file at /home/bla/file.txt, in the following format: TotalDowntime=03:02:02 Average=0.01%

View 2 Replies View Related

Programming :: Bash Time Comparison Within A Fast Moving Log?

Jun 1, 2010

I have a bash script that is tracking ERROR connections (running in a cron every 15 minutes), sometimes the errors are true and are not connecting. But most of the time, the disconnects/reconnects are between 30 seconds are sending out false positives. I am looking for a time comparison code to pick out the 30 second disconnects and know that this is and "ok" error. Here is a section of the log with timestamps, errors, etc.

Tue 2010-06-01 22:01:30 ERROR [DataBufferSendService] 172.31.0.1:8016 caught exception: [NetworkAPI] Exception: [SocketStream] socket error
Tue 2010-06-01 22:01:32 ERROR [DataBufferSendService] 172.31.0.2:8016 caught exception: [NetworkAPI] Exception: [SocketStream] socket error
Tue 2010-06-01 22:02:00 INFO [Client] 172.31.0.1:8016 connecting to 172.31.0.1 on port 8016
Tue 2010-06-01 22:02:02 INFO [Client] 172.31.0.2:8016 connecting to 172.31.0.2 on port 8016

View 8 Replies View Related

Debian :: Initial Ramdisk Freeze - One Time Yes And One Time No

Jan 13, 2016

I have a strange problem on my new installation of Debian "Stretch".

After "loading initial ramdisk" the pc freeze, but if I reboot it, then it doesn't freeze and so I could work.

So for work each time I have to boot and reboot the pc; the second time the pc works.

View 1 Replies View Related

Software :: Debian's And Debian Based Distros With Disk Space - Burn Video On Hard Drive

Aug 13, 2010

Debian and debian based distros issue has a issue that has come to make it self aware to me when I was trying to burn a video on my hard drive with braseo and it won't let me burn more than 4.4 gigs to a dvd with 4.7 gigs of free space even a file that is over the 4.4 gig limit by a megabyte with windows i didn't have this problem. One more thing I have 16 gig flash drive and on debian and debian based distros i can only use 13.1 gigs of it but on fedora I can use all 16 gigs.

View 3 Replies View Related

General :: Change File Time Stamp (Bash Script)?

Jan 6, 2010

I need some help recovering from a "slight" screwup. We just moved 3 TB of data from one RAID Array to another. Low lever archive files. This was done with a regular cp (for some reason) and now we have lost all the timestamps on the files, and we urgently need to get the timestamps back on these files.

We are running Ubuntu 9.10 Server and we have mounted the following

1. /mnt/old-raid ##Old raid from the old server
2. /mnt/new-raid ##New raid on the server

I know we can read out the timestamp on the old server using the command stat -c '%Y' <<filname>>

I know we can change the timestamp of the file, using the command touch -d '<<date>>'

To get from the stat -c date to the input date in touch we need to use date -d @<<timestamp>> +'%d %b %Y %R'

So my question is, how can I create a loop that will list all files in a folder, get their timestamp and update the old timestamp with the new?

View 4 Replies View Related

General :: Bash - Show Prints And At The Same Time Redirect It To A File?

Jul 12, 2010

I have this script in the past for csh: Code: ./a.out |& tee prints.txt which will redirect all printfs in the C program to the prints.txt file and at the same time show them in the console. How do you do this in bash? I have seen this, [URL] but it does not work for my bash and sh shells. It says:

Code: -bash: syntax error near unexpected token `&' and
Code: -sh: syntax error: unexpected "&"

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved