Sometimes it can be handy

by Stephen McGroarty 6/8/2010 7:01:00 AM

Going to try something different here, I notice that I am not paying a lot of attention to my site lately, and there isn’t a good reason not to. So for the next 30 days, until July 8th, I am going to attempt to do a post a day. I am also going to try weekends as well. The reason for this is I have a lot of things that I want to share, and I have been meaning to share from basic tech knowledge and into cars. This will also be an exercise in brushing up on my writing skills, I seem to be lacking a little bit there.

For the first post lets do a scripts to remove all the scheduled tasks on servers. We want to list all the scheduled tasks on a server, ok not a problem if you have one server you can login and view them, or you can list them remotely with

schtasks /query /s ServerName
This will return a result such as

TaskName                             Next Run Time            Status        
============================================================
FileScript1                                        23:59:00, 1/5/2010       Running        
MyTasksForStuff2                          07:00:00, 1/6/2010       Running
       

Now, you want to check the tasks on 15 servers, this gets more cumbersome and a little time consuming. So lets say you have this neat little shell script that helps you loop items so that you can one script multiple times

@echo off
 
if x==%1x goto MyServers1
if x==%2x goto MyServers2
 
for /f %%a in (%1) do call %2 %%a
goto end
 
:MyServers1
 
echo.
echo.
echo.
echo Run.bat syntax:
echo ---------------
echo.
echo Example:  run.bat list.txt program.cmd
echo.
echo 'list.txt' should contain a list of computers/IPs 
echo (one to each line) to each execute 'program.cmd'
echo.
echo The names of files are not important as long as they 
echo are specified after the run command.
echo.
echo.
echo.
echo.
 
:end

Save this as run.bat

Next we want to take our 1 line from above and put it into its own bat file with 1 change.

echo “Server Name: %1”
schtasks /query /s %1

Save that as “ViewTasks.bat”

Next we need to setup a text file that contains all the servers we want to view the scheduled task on.

Server1
Server2
Server3

Now put it all together and you will see your results

run.bat list.txt ViewTakss.bat

 

"Server Name:" Server1
TaskName                             Next Run Time            Status        
============================================================
FileScript1                                        23:59:00, 1/5/2010       Running        
MyTasksForStuff2                          07:00:00, 1/6/2010       Running
       

ServerName: Server2
TaskName                             Next Run Time            Status        
============================================================
FileScript1                                        23:59:00, 1/5/2010       Running        
MyTasksForStuff2                          07:00:00, 1/6/2010       Running
       

And you can see your tasks running. Now lets say you want to delete them. Again test with the schtasks command

schtasks /delete  /s ServerName /TN * /f

This will remove the tasks with only a complete as the last line.

So if you save this as “DeleteTasks.bat”

schtasks /delete  /s %1 /TN * /f

You can now run it as a script on all your servers with

run.bat list.txt DeleteTasks.bat

And it will remove all the scheduled tasks from your servers that you have in your list.txt

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Administration | Weekly Tip

Super Duper Postfix!

by Stephen McGroarty 1/2/2010 6:24:00 PM
Postfix + MySQL on CentOS 
Some things might not be right, but this is what worked for me, so if it doesn't work for you, sorry but this is how I did it, and it works. There are many many many links to doing this, so if this doesnt work keep searching. 

For this I started with a clean CentOS install, it was CentOS 5.4. During the CentOS install I used the advanced package options and I selected squirrelmail, httpd(web server), mysql, and I unchoose sendmail, it still installed sendmail. 

After the machine is booted and updated we then want to setup the mysql database and user.

/etc/init.d/mysqld start

mysql -u root -p 
Password: ***************************************** (not really my password, but you get the idea

mysql> create database postfix 
Query OK, 1 row affected (0.00 sec)

mysql> grant all on postfix.* to 'postfixuser'@'localhost' identified by 'MySuperSecurePassword!'; 
Query OK, 0 rows affected (0.00 sec)

now we want to add the postfix packages. 

/etc/init.d/sendmail stop 
yum remove sendmail 
yum install php-mysql spamassassin php php-mbstring postfix 

Postfix should now be installed, but it is missing some things. 
[root@localhost ~]# postconf -m
btree
cidr
environ
hash
ldap
nis
pcre
proxy
regexp
static
unix

If you notice, there is not MySQL support in there. That is in a special package in the CentOS Plus repo. 
wget http://mirror.centos.org/centos-5/5.4/centosplus/i386/RPMS/postfix-2.3.3-2.el5.centos.mysql_pgsql.i386.rpm 

When you do the rpm install it will tell you that you need postgressql, i just installed it and made sure it was off and the service was off.
yum install postgresql 

When you install postfix from the RPM it will tell you that you have a newer version on your system, and that is why we are using the --force 
rpm -U postfix-2.3.3-2.el5.centos.mysql_pgsql.i386.rpm --force  

Restart the server/service then run the postconf -m again to verify the MySQL support
[root@localhost ~]# postconf -m
btree
cidr
environ
hash
ldap
mysql
nis
pcre
pgsql
proxy
regexp
static
unix

Next we want to add Postfix Admin, there is no RPM for this, but it is a simple web application that will setup the tables in the database for you. 

http://sourceforge.net/projects/postfixadmin/
Because this is going to be a straight mail server, I just untared it in the /var/www/html directory and set it up from there. This is a nice utility for managing and maintaining users, and you can create admins per domain so that they can manage their own accounts. 

connect to the server at the postfix admin URL and configure that, it will allow you to configure the databases even though we haven't setup postfix to use the databases yet. 

After you have postfix admin configured it is time to add the magic to the postfix/main.cf file. 
You want to change it to allow users 
Be sure to find the corisponding lines here and comment them out or change them in the main.cf

#MySQL DB properties
# This is for the virtual users 
virtual_alias_maps = mysql:/etc/postfix/virtual_alias_maps.cf
# the group id that postfix runs as 
virtual_gid_maps = static:89
# Create this directory and chmod -R postfix:postfix /home/vmail 
virtual_mailbox_base = /home/vmail
# this will be the domains that are allowed to send/receive on the box 
virtual_mailbox_domains = mysql:/etc/postfix/virtual_domains_maps.cf
# mailboxes 
virtual_mailbox_maps = mysql:/etc/postfix/virtual_mailbox_maps.cf
# more user and groupIDs 
virtual_minimum_uid = 89
virtual_mailbox_uid = 89
# we want the transport type to be virtual instead of physical 
virtual_transport = virtual
virtual_uid_maps = static:89

And the Database connections

cat virtual_alias_maps.cf
user = postfixdatabaseuser
password = password
host = localhost
dbname = postfix
table = alias
select_field = goto
where_field = address

cat virtual_alias_maps.cf
user = postfixdatabaseuser
password = password
host = localhost
dbname = postfix
table = alias
select_field = goto
where_field = address

cat virtual_domains_maps.cf
user = postfixdatabaseuser
password = password
hosts = localhost
dbname = postfix
table = domain
select_field = description
where_field = domain

Restart the postfix server, add to local users with postfix admin, and use squirrelmail to verify that you can send and receive emails.

Again this is a general overview, email me if you have any questions.
Edits might be made to this as time goes on as well.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

From the mouth of madness

by Stephen McGroarty 12/19/2009 3:23:00 PM

So I am using an odd assortment of things in my little world. I have Windows 7, Windows Vista, and Debian Linux on my work/home machines and strangely enough they all have web cams. With that I remembered that I have an account over at UStream.tv and that I did broadcast before, so why not do it again. 

Found the only issue is that my debian desktops dont like to broadcast, this seems to be a common issue with Linux desktop because Flash does not prompt you to allow or deny  the application. In poking around I found the application WebCam Studio for Linux and on the bottom of the "Installing on Ubuntu" page was the answer. 

1. Close all browsers

2. Go here:  http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager06.html

3.  Find "www.ustream.tv" and "cdn1.ustream.tv" and change them from "Always Ask" to "Allow" 

4. restart web browser, go to UStream.tv, login, and click broadcast. 

If your camera does work in linux you should not be able to broadcast.

If this doesnt work, make sure your webcam works in general because this is only a solution for broadcasting on websites, not making your cam work.  

I might do another post tonight if i am feeling motivated enough 

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

Weekly Tip

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen
Hacked by Stephen McGroarty
Content © Stephen McGroarty


About the author

Stephen Mcgroarty - Avatar Stephen McGroarty

I am a Microsoft Certified Professional with Windows 2003 Server. I have a firm understanding of Linux, Windows, and everything needed for both workstation and servers.

E-mail me Send mail

Calendar

<<  September 2010  >>
SuMoTuWeThFrSa
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

View posts in large calendar

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010