[SOLVED] Find all users with a MAILTO option in their crontab

Anyone know if this is possible? I have a script that lists all scheduled cronjobs but I need to find out which users have email notifications configured.
If anyone else wants it, here is the script I use to check all user's crontabs. I did not write this.. just found it a while back.
#!/bin/bash
# System-wide crontab file and cron job directory. Change these for your system.
CRONTAB='/etc/crontab'
CRONDIR='/etc/cron.d'
# Single tab character. Annoyingly necessary.
tab=$(echo -en "\t")
# Given a stream of crontab lines, exclude non-cron job lines, replace
# whitespace characters with a single space, and remove any spaces from the
# beginning of each line.
function clean_cron_lines() {
while read line ; do
echo "${line}" |
egrep --invert-match '^($|\s*#|\s*[[:alnum:]_]+=)' |
sed --regexp-extended "s/\s+/ /g" |
sed --regexp-extended "s/^ //"
done;
# Given a stream of cleaned crontab lines, echo any that don't include the
# run-parts command, and for those that do, show each job file in the run-parts
# directory as if it were scheduled explicitly.
function lookup_run_parts() {
while read line ; do
match=$(echo "${line}" | egrep -o 'run-parts (-{1,2}\S+ )*\S+')
if [[ -z "${match}" ]] ; then
echo "${line}"
else
cron_fields=$(echo "${line}" | cut -f1-6 -d' ')
cron_job_dir=$(echo "${match}" | awk '{print $NF}')
if [[ -d "${cron_job_dir}" ]] ; then
for cron_job_file in "${cron_job_dir}"/* ; do # */ <not a comment>
[[ -f "${cron_job_file}" ]] && echo "${cron_fields} ${cron_job_file}"
done
fi
fi
done;
# Temporary file for crontab lines.
temp=$(mktemp) || exit 1
# Add all of the jobs from the system-wide crontab file.
cat "${CRONTAB}" | clean_cron_lines | lookup_run_parts >"${temp}"
# Add all of the jobs from the system-wide cron directory.
cat "${CRONDIR}"/* | clean_cron_lines >>"${temp}" # */ <not a comment>
# Add each user's crontab (if it exists). Insert the user's name between the
# five time fields and the command.
while read user ; do
crontab -l -u "${user}" 2>/dev/null |
clean_cron_lines |
sed --regexp-extended "s/^((\S+ +){5})(.+)$/\1${user} \3/" >>"${temp}"
done < <(cut --fields=1 --delimiter=: /etc/passwd)
# Output the collected crontab lines. Replace the single spaces between the
# fields with tab characters, sort the lines by hour and minute, insert the
# header line, and format the results as a table.
cat "${temp}" |
sed --regexp-extended "s/^(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(\S+) +(.*)$/\1\t\2\t\3\t\4\t\5\t\6\t\7/" |
sort --numeric-sort --field-separator="${tab}" --key=2,1 |
sed "1i\mi\th\td\tm\tw\tuser\tcommand" |
column -s"${tab}" -t
rm --force "${temp}"
Last edited by thelastknowngod (2011-11-28 22:14:33)

Perhaps I'm missing something here, but...
grep -i MAILTO /var/spool/cron/*

Similar Messages

  • Find all users with deleagtion

    Hello,
    I am looking for a powershell script that will report ( csv ) on all users with delegation in the O365 environment. Any help would be appreciated.

    Hey
    This can help you:
    http://community.spiceworks.com/topic/449787-exchange-2010-list-delegate-full-access-information-for-all-users
    Regards.

  • XPRESS code to find all users with a specific Admin Role

    I've been playing around for a while with a way to get a list of all users that have been assigned a particular Admin Role. I have a role for which I want a specific subset of users to be approvers on it, and I want to greate a Rule that will check for people with a particular Admin Role and then return that list as people to be approvers on the role.
    I haven't been able to find an easy way to write this code. Anyone run across this before or have another suggestion???
    Thanks.

    Below is the code to find user based on condition.
    <set name='adminList'>
    <invoke name='getObjectNames' class='com.waveset.ui.FormUtil'>
    <ref>:display.session</ref>
    <s>User</s>
    <map>
    <s>conditions</s>
    <list>
    <new class='com.waveset.object.AttributeCondition'>
    <s>AdminRoles</s>
    <s>contains</s>
    <s>adminRoleName</s>
    </new>
    </list>
    </map>
    </invoke>
    </set>
    Edited by: Jay on Mar 7, 2012 4:03 AM

  • Retrieve all users with attributes from AD

    hi,
    i'd like to retrieve all users with their attributes from AD. I can connect to AD and i 'm able to retrieve entries from a group with the member class given in this forum.
    But my problem is i would like to retrieve users directly from the Users container
    thanx for help

    i solved one part of my problem.
    But, now i have to get all attributes for each users and i couldn't find them. The getattributes method doesn't return anything (i 'd like to retrieve the first name, last name, adress ...)
    thanx for help

  • How do I find all pictures with no (empty) keyword ?

    I have decided to import all my pictures into LightRoom.
    A lot of my older pictures are not registered with any keywords :(
    - only with IPTC location information.
    My plan is to systematic go through all my pictures and add relevant keywords to all pictures - so my old pictures become as searchable as my newest pictures.
    Some of my old pictures has keywords some has not.
    How do I in Lightroom - find all pictures with no keywords?
    I have tried to use the Find tool - but don't see any options to search for "Empty/missing" keywords.
    Also I would like to find all pictures with few keywords and in step II add additional keywords to these pictures.
    Any ideas on how to make a find all pictures where number of keywords is less than X inside or outside LightRoom.
    Henrik Bach
    Denmark

    > I also did think of the SQL idea.
    > If I find a way of doing this I will repost my findings.
    Well, being a tech geek, I found this challenge kind of irresistible,
    and I'm happy to report I have a solution for you.
    STEP 1
    First, make a copy of your "Lightroom Database.lrdb" file (we'll work
    off the copy to be safe)
    STEP 2
    Next, you need to be able to browse the database. The database is in
    SQLite3 format. I tried installiing an SQLite3 ODBC driver and accessing
    it through MS Access 2003. While Access was able to see all of the
    tables in the database, every time I tried to link to one I got:
    "Reserved error (-7748); there is no message for this error"
    I found a few tips for this but wasn't able to work around it and get it
    to work. Which is a shame, since Access would be the easiest way for
    browsing and querying tables.
    Instead I found an open source tool called SQLite Database Browser.
    http://sourceforge.net/project/showfiles.php?group_id=87946&package_id=91778&release_id=41 4746
    I used the Windows version. There appears to be a version for MacOSX on
    PowerPC. It doesn't look like there is a version for Intel based Macs
    (though if you know how, you could always try downloading the source and
    compiling it yourself).
    STEP 3
    After you install the browser, open it up, choose "Open Database" and
    select the COPY of the lightroom database we made in step 1
    STEP 4
    go to the Execute SQL tab and issue the following command
    SELECT A.idx_filename, count(C.name)
    FROM Adobe_imageFiles A, AGLibraryTagImage B, AGLibraryTag C
    WHERE A.image=B.image AND B.tag=C.id_local AND C.kindName='AgKeywordTagKind'
    GROUP BY A.idx_filename
    HAVING count(C.name) <= 3
    That will give you all images with 3 or fewer keywords applied.
    Of course, theres no guarantee that this wont break in future versions.
    Now an explanation of the data.
    Adobe_imageFiles - contains data about image files:
    1) idx_filename is the filename
    2) absolutePath is the full file path
    3) image is a unique ID for the image which you can cross reference in
    other image related tables
    AGLibraryTag - contains info about "tags" applied to images:
    1) id_local is a unique ID for this "tag", which you can use to cross
    reference in other tag tables
    2) kindName is the kind of tag you are looking at. Available values
    appear to be:
    AgCaptionTagKind
    AgCollectionTagKind
    AgCopyrightTagKind
    AgEnumeratedMetadataTagKind
    AgFolderTagKind
    AgImportTagKind
    AgKeywordTagKind
    AgMissingFileTagKind
    AgQuickCollectionTagKind
    AgSpecialContentOwningTagKind
    AgTempImagesTagKind
    3) name is the value for that tag (the collection name, the keyword, etc)
    AGLibraryTagImage - Use this to connect the images and tags tables

  • List all users with full control on a SharePoint 2013 Sub site from SharePoint Object Model in C#

    If I have a sub site URL and a user with Site Admin, can I list all users in that sub site that have Full Control at that level?
    Any C# code sample?

    Still you can do that, just pass the subsites to your code and from their you can find the users dynamically.
    You could also use SPWeb.Users property to get users assigned to a subsite
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.users(v=office.15).aspx
    alternatively you can also use SPWeb.SiteUsers to get all users
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.siteusers(v=office.15).aspx
    other APIs of help-
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.associatedmembergroup(v=office.15).aspx
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.associatedownergroup(v=office.15).aspx
    http://sharepoint.stackexchange.com/questions/101671/object-model-list-all-users-with-full-control-on-a-sub-site-in-sharepoint-2013
    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if my reply helps you

  • Javascript: Query all users with read permission to specific list

    Is it possible to use javascript to retrieve all users with read permissions to specific list? This (http://www.c-sharpcorner.com/UploadFile/anavijai/how-to-get-all-the-users-from-site-group-in-sharepoint-2013/) shows how to get users from group but what
    about list. All users in list may not exist in spgoups.

    Hi,
    If with Server Object Model which is executed in server side, in the
    SPList object, there is a
    RoleAssignments property can help to get what you want without looping through all the users in site:
    public static void getPermissionsOfList()
    using (SPSite site = new SPSite("http://sp"))
    using (SPWeb web = site.RootWeb)
    SPList list = web.GetList("/Lists/List1");
    SPRoleAssignmentCollection roles = list.RoleAssignments;
    foreach (SPRoleAssignment role in roles)
    Console.WriteLine("~");
    Console.WriteLine("Name: " + role.Member.Name);
    SPRoleDefinitionBindingCollection bindings = role.RoleDefinitionBindings;
    XmlDocument doc = new XmlDocument();
    doc.LoadXml(bindings.Xml);
    //Console.WriteLine(doc.InnerXml);
    XmlNodeList itemList = doc.DocumentElement.SelectNodes("Role");
    foreach (XmlNode currNode in itemList)
    string s = currNode.Attributes["Name"].Value.ToString();
    Console.WriteLine("Permission Level: " + s);
    However, when comes to JavaScript Client Object Model, as there is no such property provided, I suggest you take the solution provided in my previous post for a try.
    Thanks 
    Patrick Liang
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • I need a SQL to find all users within OID

    Hi,
    I'm trying to find all usernames and last logon in OID and was thinking of two ways to do this.
    1. query OID with ldapsearch
    2. query LDAP schema in Oracle database.
    Any ideas on how to do this and what is the best way. If a sql in the database could solve this it would really be the best way for me.
    Regards
    Morten

    I did a:
    SELECT DISTINCT user_name
    FROM orasso.wwsso_audit_log_table_t
    WHERE action_code = 1001
    But this only gives me the users that have loged on to SSO.. I need all users even those who haven't loged on.
    All help will be really good.
    Regards

  • How to provision an app for all users with all dependencies?

    I have created an app package with VS that I want to provision for all users of a target system using
    DISM /Online /Add-ProvisionedAppxPackage /FolderPath:".\%package%" /SkipLicense
    The path contains the content of the *Test folders VS creates when creating store packages. However DISM expects a ".main" file in this folder to work (0xc1570102).
    What's the correct way to provision an app with all its dependency packages? (Using the PackagePath option?)

    After some further testing in Profile Manager I found that adding the applescript to items that open at logon seems to work. No need for the plist, unless of course I decide not to use Profile Manager at all.

  • Find All PDFs With Extensions Enabled?

    I need to search through thousands of PDFs in multiple folders to find all of those that have extensions enabled.
    Anyone know of a tool that would so that?
    (preferable free)
    Thanks
    Mathias

    As far as we understand it
    If we post a pdf to a website with the extensions enabled where a user can save a PDF with data in the form fields
    And more than 500 copies of that PDF are distributed, extra licensing is required
    http://en.wikipedia.org/wiki/Adobe_LiveCycle_Reader_Extensions
    That is why I am looking for a way to scan all of our PDFs.
    Thanks

  • Find all users who have delegated items to me.

    i need a rule / something, by which i can find all the active delegations assigned to me on my end user screens.
    It may be from my manager , or from any other user.
    I checked the user object and noticed that only the person who delegates has the information stored, and nothing in my user object.
    Any recommendations would be aapreciated.

    It is not possible to accomplish this by using powershell. Easier one is to get the list of people who has access on something with below and do easier data manipulation in Excel :
    Get-Mailbox -Resultsize Unlimited | Get-MailboxPermission | ?{$_.isinherited -eq $False -and $_.user -notlike "*self*"} | select identity, user,accessrights
    [url=http://www.lepide.com/]Lepide[/url]

  • Reports in GC: show all users with status != 'OPEN' (locked users)

    Hello,
    I would like to create a report in GC which shows all users of a given database with status != 'OPEN'.
    To create a report is not the problem - but which view/table of the GC repository contains the needed information about the status of the database users?
    I've already looked through alot of the mgmt$... views - but didn't find any information about the user status...
    Any help will be appreciated...
    Rgds
    JH

    The reports of the GC are using the repository of the GC. Therefore you will only find the users of that repository in sys.dba_users. What I need are the users of a database which is monitored through an agent of the GC.
    Rgds
    JH

  • Script to find active users with responsibility

    Dear all,
    r12.0.4 on solaris 10
    I need a script to find out the users with all the responsibilities attached to the user ..can anyone share the query if u have ?
    Kai

    Kai,
    Please see (Note: 8576725 - Tom's Handy SQL for the Oracle Applications), 2.3. Users and Responsibilities.
    You can also submit the "Active Users" concurrent program.
    There are many scripts available in the forum, you can also use them.
    Query Responsibilities
    Re: Query Responsibilities
    Regards,
    Hussein

  • Outlook 2010 not finding all users in the "To" line

    I have a user that has an issue with searching in the "To" line when sending an email.
    She has sent an email to this person before, and with most users, she can type first or last name and come up with the users. But there are a select few that she can only find by typing their last name. I understand that while she can still find the user
    under the last name, she is wanting to find the users by first name. I have removed cached mode, removed the cached email address and put it back in by sending a test email to the other person, but no luck, and I have gone in and found the user in the global
    address book (Which searches by last name) and nothing This user can only be found by last name. I have been told that she can only search by last name if it someone who is in our organization, and I verified that the person she is sending to is on our domain
    and is not an outside user.
    Is there something I am missing or can try so that I can fix this for the lady who wants it to be the same across the board, or is this something that she will unfortunately just have to deal with.
    Thanks,
    Carter

    Hi,
    After some research, I found that when we search for a recipient by the text we type in, auto-complete looks at the following fields:
    1.Display Name
    2.Primary SMTP E-mail address (i.e. [email protected])
    3.Exchange Alias (i.e. abc)
    4.legacyExchangeDN attribute in Active Directory
    Auto-complete does not search against any of the following criteria:
    1.First Name (if it is different from the display name, for example if the display name contained a nickname instead of the legal first name, which is listed in the recipients’ “first name” field in Active Directory)
    2.Last Name (unless one of the above four fields starts with the last name)
    3.Username (unless one of the above four fields starts with the username, or is set to match the username)
    Please add the recipient's name(especially first name as the sender need) to the display name of the local contact, this should work.
    Thanks,
    Melon Chen
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please click
    here

  • PSE7: Find all photos with any caption?

    I'm running PSE7.
    I have a sub-set of my images selected via a tag.
    Now I want to find all of images in that set that have any caption at all.
    So I do a Find/By Caption or Note.
    Now in the next dialog box is there some way that I can enter a wild card or something
    that will find any image that has anything in it at all?
    Thanks for any help!

    Ouch!!
    Well, I understand the solution you described.
    Let me back up a bit. And describe what I'm trying to accomplish.
    I take a bunch of pictures and I bring them in Organizer.
    I go through them quickly adding 'notes' to them.
    Who the people are, where this is, etc. etc.
    I just add them in the Caption because that is a single click in Organizer.
    Very easy.
    But I don't add captions to every image.
    Later I go back and I want to add Text to these images in Editor.
    Basically, I want to permanently include my 'notes' with these images.
    So anytime someone views or prints the jpeg they are going to see my notes.
    So my original question was how I can select that group of captioned images
    in Organizer. Then I was going to Ctrl-i and get them all into Editor.
    But maybe there is another way for me to select just those images?
    In Organizer, it seems the only way I can 'see' the captions is when the image
    is in 'Single Photo View'. Which is ok. But as far as I can tell, when I am in
    Single Photo View I can't 'Select' that image. Maybe I'm missing something.
    Anyway, if I could Select that image, then I would just move through the rest
    of my images in Organizer. When I saw another captioned one I would want
    to do the equivalent of Ctrl-click. Adding that image to the other images that
    I have selected.
    Well, that's the story. Is there another way I can skin this cat?
    Thanks!

Maybe you are looking for

  • XML parser for Java setup

    I download the XML Parser for Java 3.2.1 Release from the IBM site and I have JDK1.3 installed on my Windows 2000 PC. I've placed the files "xerces.jar" and "xalan.jar" in the location specified by the extensions mechanism (i.e "C:\JDK1.3\jre\lib\ext

  • Exclusive connection iPad to Apple TV

    We use iPads and Apple TVs at my University for presentations.  I find however that a few minutes after I make the connection, it drops out, and I suspect that someone else on the network is accidentally (or otherwise) making the connection to the sa

  • Exception field traffic light

    Hi any one can help me how to display the details in exceptions field traffic light . i am facing the problem in execption field. ALV lisst  is displaying in all other field but not showing in exception field.

  • OracleOra9ias_homeManagementServer Version 2.2 NOT START

    OracleOra9ias_homeManagementServer Version 2.2 do not start on Windows 2000 5.00.2195 Service Pack 4. The error message says: The service did not respond to the start or control request in a timely fashion Those anybody knows what this means .... bas

  • Why does the iPad Air Smart Case not sit flush?

    I bought one today and was immediately disappointed. When the cover is closed the first 1/3 sections (closest to the hinge) is raised above the screen. When it's fully opened in 'reading' mode, the cover lumps up on the back of the iPad. This makes i